Forum Discussion
PowerShell WriteError: InvokePowerBIRestMethod when authenticated with Connect-PowerBIServiceAccount
Hi,
I have a PowerShell script which is erroring out. When I authenticate with "Login-PowerBI", the script works perfectly. When I authenticate with Connect-PowerBIServiceAccount it errors out.
I am using Connect-PowerBIServiceAccount, because I have to automate the script.
Here is the portion of the script which can replicate the issue:
$applicationId = 'AzureAppClientID';
$securePassword = 'AzureAppSecretValue' | ConvertTo-SecureString -AsPlainText -Force
$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $applicationId, $securePassword
Connect-PowerBIServiceAccount -ServicePrincipal -Credential $credential -TenantId 'AzureAppTenantID'
Invoke-PowerBIRestMethod -Url 'apps' -Method Get
Here are the API permissions in Azure:
12 Replies
- willz06jwHelper II
I have added my service principle (which for people wondering, is automatically created when I registered my Azure App) to the security group which is listed on this Power BI tenant setting, but the PowerShell script still crashes when I authenticate using this method.
- willz06jwHelper II
Here is what it says when I run the script:
- m-colbertResolver III
Which API method are you trying to invoke? If you are trying to inboke a method that is not an admin method, than the service principal must have access to the workspace.