< Back

Get-PBIAuthToken

Sat Jan 18, 2020 8:41 pm

NAME Get-PBIAuthToken



SYNOPSIS

Gets the authentication token required to comunicate with the PowerBI API's





SYNTAX

Get-PBIAuthToken [[-credential] <Object>] [-forceAskCredentials] [[-clientId] <String>] [[-redirectUri] <String>]

[[-tenantId] <String>] [[-clientSecret] <String>] [-returnADALObj] [-deviceCodeFlow] [[-tokenCacheFile] <String>]

[<CommonParameters>]





DESCRIPTION

To authenticate with PowerBI uses OAuth 2.0 with the Azure AD Authentication Library (ADAL)



If a credential is not supplied a popup will appear for the user to authenticate.



It will automatically download and install the required nuget: "Microsoft.IdentityModel.Clients.ActiveDirectory".





PARAMETERS

-credential <Object>

Specifies a PSCredential object or a string username used to authenticate to PowerBI. If only a username is

specified

this will prompt for the password. Note that this will not work with federated users.



Required? false

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



-forceAskCredentials [<SwitchParameter>]

Forces the authentication popup to always ask for the username and password



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-clientId <String>

The Client Id of the Azure AD application



Required? false

Position? 2

Default value

Accept pipeline input? false

Accept wildcard characters? false



-redirectUri <String>

The redirect URI associated with the native client application



Required? false

Position? 3

Default value

Accept pipeline input? false

Accept wildcard characters? false



-tenantId <String>

The Azure AD Tenant Id, optional and only needed if you are using the App Authentication Flow



Required? false

Position? 4

Default value

Accept pipeline input? false

Accept wildcard characters? false



-clientSecret <String>

The Azure AD client secret, optional and only needed it the ClientId is a Azure AD WebApp type



Required? false

Position? 5

Default value

Accept pipeline input? false

Accept wildcard characters? false



-returnADALObj [<SwitchParameter>]



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-deviceCodeFlow [<SwitchParameter>]



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-tokenCacheFile <String>



Required? false

Position? 6

Default value

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS

System.String





-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Get-PBIAuthToken -clientId "C0E8435C-614D-49BF-A758-3EF858F8901B"













-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Get-PBIAuthToken -ClientId "C0E8435C-614D-49BF-A758-3EF858F8901B" -Credential (Get-Credential)













-------------------------- EXAMPLE 3 --------------------------



PS C:\\>Get-PBIAuthToken -ClientId "C0E8435C-614D-49BF-A758-3EF858F8901B" -tenantId "company.onmicrosoft.com"

-clientSecret "Azure AD APP Secret"















RELATED LINKS