Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi,
we are trying extract the list of pending access requests for Power BI reports and Apps using the Rest API, but we are not able extract it. Snippet of the code is as follows. We are getting blank excel after executing this code.
any help is appreciated. Please suggest if any other method to get the list of Pending request for reports and Apps.
# Connect to Power BI service (make sure you run this first)
Connect-PowerBIServiceAccount
# Get all workspaces
$workspaces = Get-PowerBIWorkspace
# Loop through each workspace
foreach ($workspace in $workspaces) {
Write-Host "Workspace: $($workspace.Name)"
# Get all reports in the workspace
$reports = Get-PowerBIReport -WorkspaceId $workspace.Id
# Loop through each report
foreach ($report in $reports) {
Write-Host " Report: $($report.Name)"
# Get manage permissions information
$url = "https://api.powerbi.com/v1.0/myorg/admin/reports/$($report.Id)/users"
$permissions = Invoke-PowerBIRestMethod -Url $url -Method Get | ConvertFrom-Json
# Display pending users
$pendingUsers = $permissions.value | Where-Object { $_.principalType -eq "User" -and $_.userState -eq "Pending" }
if ($pendingUsers) {
Write-Host " Pending Users:"
foreach ($user in $pendingUsers) {
Write-Host " - $($user.emailAddress) (Access: $($user.accessRight))"
}
} else {
Write-Host " No pending users for this report."
}
Write-Host ""
}
Write-Host ""
}
# Disconnect from Power BI service
Disconnect-PowerBIServiceAccount
Solved! Go to Solution.
Thanks for the reply from lbendlin please allow me to provide another insight:
Hi, @sreedhary .
Your idea is excellent and certainly a good approach to automation. However, I share Benzerlin's view that if you wish to use the API you provided to obtain a list of individuals requesting access, this is currently not supported. Here are my findings from testing:
1.Firstly, aside from the administrators, there is one individual who has applied for access to the report.
2.Secondly, I conducted tests using the API you provided,here are the final results:
The evidence clearly shows that it is indeed not possible to retrieve the list of individuals currently applying for access.
I recommend that you temporarily handle the applicant information through manual queries.
Of course, you might also consider accepting lbendlin's response as a solution, as this would allow other members with similar thoughts to find the post more quickly and vote on your idea.
If you have any new ideas, you are welcome to contact us.
Best Regards,
Leroy Lu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks for the reply from lbendlin please allow me to provide another insight:
Hi, @sreedhary .
Your idea is excellent and certainly a good approach to automation. However, I share Benzerlin's view that if you wish to use the API you provided to obtain a list of individuals requesting access, this is currently not supported. Here are my findings from testing:
1.Firstly, aside from the administrators, there is one individual who has applied for access to the report.
2.Secondly, I conducted tests using the API you provided,here are the final results:
The evidence clearly shows that it is indeed not possible to retrieve the list of individuals currently applying for access.
I recommend that you temporarily handle the applicant information through manual queries.
Of course, you might also consider accepting lbendlin's response as a solution, as this would allow other members with similar thoughts to find the post more quickly and vote on your idea.
If you have any new ideas, you are welcome to contact us.
Best Regards,
Leroy Lu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
There is no "userState" attribute for that call.
Admin - Reports GetReportUsersAsAdmin - REST API (Power BI Power BI REST APIs) | Microsoft Learn
If this is important to you please consider voting for an existing idea or raising a new one at https://ideas.fabric.microsoft.com
Is there anyway to see users that have requested access at all? Would they have a userType of NONE or something like that?
Anyway to do a mismatch check?