-
Notifications
You must be signed in to change notification settings - Fork 66
Description
#Login to Power BI
$username = "[email protected]"
$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