Forum Discussion
Power Shell Invoke-PowerBIRestMethod -Method Post failing
Hi mjbirrer
Can you confirm that the app that was created in AAD has got the correct permissions from the person who created it?
I was the one that created it. These are the permissions I have added. Notice the warning on the tenant permission.
Here is the script i'm trying to run. Basically pull all workspaces and associated users. I can do this for my workspaces, but when i open it up to -Scope Organization, it fails.
Invoke-PowerBIRestMethod : One or more errors occurred.
At C:\Users\jeffrey.birrer\Documents\PowerBI\PowerBI_ExportContent_NEW.ps1:38 char:13
+ $wkpacc = Invoke-PowerBIRestMethod -Url $APIUrl -Method Get|Convert ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (Microsoft.Power...werBIRestMethod:InvokePowerBIRestMethod) [Invoke-PowerBIRestMethod], AggregateException
+ FullyQualifiedErrorId : One or more errors occurred.,Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod
# Authenticate to the Power BI Service API
Connect-PowerBIServiceAccount
# Arrays to hold retrieved data
$access = @()
# Get the workspace data
$workspaces = Get-PowerBIWorkspace #-All -Scope Organization | Where-Object { $_.State -match 'Active' }
ForEach($Workspace in $Workspaces)
{ $wkpacc = @()
$Wkpname = $Workspace.Name
$wkpid = $Workspace.Id
$APIUrl = 'groups/'+$wkpid+'/users'
$wkpacc = Invoke-PowerBIRestMethod -Url $APIUrl -Method Get|ConvertFrom-Json|SELECT -ExpandProperty Value|SELECT displayName,groupUserAccessRight|Add-Member -MemberType NoteProperty -Name WorkspaceName -Value $Wkpname -PassThru
$access += $wkpacc
}
$access | Export-CSV "C:\Users\jeffrey.birrer\Desktop\PowerBI_WorkspaceUsers.csv" -NoTypeInformation