< Back

Get-PowerBIAccessToken

Sat Jan 18, 2020 4:14 pm

NAME Get-PowerBIAccessToken



SYNOPSIS

Gets the access token for your current Power BI authenticated session.





SYNTAX

Get-PowerBIAccessToken [-AsString] [<CommonParameters>]





DESCRIPTION

Returns the Power BI access token gathered from logged in Power BI profile. Before you run this command, make sure

you log in using Connect-PowerBIServiceAccount.





PARAMETERS

-AsString [<SwitchParameter>]

Indicates to return the access token as a string instead of a hashtable. The string contains the

authentication type, such as "Bearer".



Required? false

Position? named

Default value False

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

None







OUTPUTS

System.Object







NOTES









-------------------------- Example 1 --------------------------



PS C:\\> $headers = Get-PowerBIAccessToken

PS C:\\> Invoke-RestMethod -Headers $headers -Uri 'https://api.powerbi.com/v1.0/myorg/groups'



Gets the Power BI access token as a hashtable and passes it to Invoke-RestMethod, as part of the header, to

authenticate.



RELATED LINKS

Online Version: https://docs.microsoft.com/en-us/powers ... biaccessto

ken?view=powerbi-ps