Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
dandurocher
Frequent Visitor

PowerShell Script for retrieving Audience information from Power BI Workspace

Hello,
I am looking to write a PowerShell script that will retrieve all available information pertaining to Audiences in Power BI, including which reports are published to which audience, and which users or groups have viewing permissions to each audience.
When I asked Bing AI on Sunday, it happily returned this script:

 

# Load the Power BI module
Import-Module MicrosoftPowerBIMgmt

# Login to Power BI service
Login-PowerBI

# Get the workspace ID by name
$workspace = Get-PowerBIWorkspace -Name "My Workspace"

# Get the app ID by workspace ID
$app = Get-PowerBIApp -WorkspaceId $workspace.Id

# Get the audiences for the app
$audiences = Get-PowerBIAppAudience -AppId $app.Id

# Loop through each audience and get all available information for it
foreach ($audience in $audiences) {
    Write-Host "Audience: $($audience.Name)"
    Write-Host "ID: $($audience.Id)"
    Write-Host "Description: $($audience.Description)"
    Write-Host "Created By: $($audience.CreatedBy)"
    Write-Host "Created On: $($audience.CreatedOn)"
    Write-Host "Modified By: $($audience.ModifiedBy)"
    Write-Host "Modified On: $($audience.ModifiedOn)"
    Write-Host "Users or groups:"
    $users = Get-PowerBIAppAudienceUser -AppId $app.Id -AudienceId $audience.Id
    foreach ($user in $users) {
        Write-Host "$($user.DisplayName) ($($user.EmailAddress))"
    }
}


Two days later, this seems to have disappeared from Bing. The command Get-PowerBIAppAudience doesn't seem to exist anywhere on the Internet. Bing now recommends an imaginary URL about a non-existent Operation on the REST API page.

We have hundreds of workspaces in our tenant, each with or without an audience for its published reports. Retrieving this information manually is not a feasible solution.

Does there exist a cmdlet or script that will return the desired information?

6 REPLIES 6
thevaibhav
New Member

@dandurocher did you get any resolution for this?

No, still not possible. And believe it or not but there is also no systemic link between App ID and workspace ID in any of the APIs.

darwindat
Helper I
Helper I

Does anyone have the answer to this question? The Scanner API doesn't include the Users of PBI App Audience. As I see, there is nowhere that we can extract that information automatically. 

@darwindat  you are unfortunately correct. I checked the Scanner API (as I should have done before posting) and there's no coverage of audience membership. Apologies.

 

If this is important to you please consider voting for an existing idea or raising a new one at https://ideas.fabric.microsoft.com/?forum=2d80fd4a-16cb-4189-896b-e0dac5e08b41

 

 

<sad tuba>womp womp</sad tuba>

 

Thank you for looking into this. I appreciate your time even if the answer doesn't solve my problem.

lbendlin
Super User
Super User

Check the Scanner API. It should cover that part of the meta data.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.