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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors