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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors