Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Login and retrieve token via Powershell to use for Clear-PBITableRows #62

Open
MarkusSacramento86 opened this issue Dec 11, 2019 · 0 comments

Comments

@MarkusSacramento86
Copy link

#Login to Power BI
$username = "name.surname@domain.se"
$password = "ENCRYPTED PASSWORD"
$cred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $username,($password | ConvertTo-SecureString)
Login-PowerBI -Credential $cred
#Retrieve token while logged in
$PowerBIToken = Get-PowerBIAccessToken -AsString
#Trying to clear table with retrieved token
Clear-PBITableRows -authToken $PowerBIToken -DataSetId "f666h111-e553-8f64-7428-72vr74sdf57j" -TableName "RealTimeData"
#Disconnect from Power BI
Disconnect-PowerBIServiceAccount

Above code works to login my account to Power BI.
I´ve managed to store PowerBIAccessToken to a variable.
But I can´t use that variable as token when trying to clear the data.
I recieve below error:

Invoke-PBIRequest : The remote server returned an error: (403) Forbidden. - ''
At C:\Program Files\WindowsPowerShell\Modules\PowerBIPS\PowerBIPS.psm1:1410 char:5
+ Invoke-PBIRequest -authToken $authToken -method Delete -resource ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WebException
+ FullyQualifiedErrorId : System.Net.WebException,Invoke-PBIRequest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant