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
AUaero
Responsive Resident
Responsive Resident

Office 365 groups vs Power BI workspaces

Hi,
I'm using the Invoke-PowerBIRestMethod cmdlet in Powershell to enumurate the reports in a given workspace.  First, I'm getting the workspaces using the Get-PowerBIWorkspace cmdlet and storing that in a variable:

 

# get a list of all the workspaces in the tenant
$workspaces = Get-PowerBIWorkspace -Scope Organization -All -Filter "tolower(type) eq 'group'"

 

Then I'm looping through each workspace to enumerate the reports.

 

# get a list of all reports in the tenant
$reports = foreach ($workspace in $workspaces)
{
    if($workspace.State = "Active") 
    {
        $URL = "https://api.powerbi.com/v1.0/myorg/groups/" + $workspace.Id + "/reports"
        $reports = Invoke-PowerBIRestMethod -Url $URL -Method GET
    }
}

 

The problem I'm running into is that the Get-PowerBIWorkspaces returns all workspaces in the tenant, including all the automatically created Office 365 groups.  When I pass the workspace ID for one of the O365 groups to the Power BI API to get the reports, I get an error.

Is there any way to programatically filter the workspaces to return *only* actual Power BI workspaces and exclude the O365 groups?

Thanks!

 

1 REPLY 1
Greg_Deckler
Super User
Super User

Perhaps use a try/catch block?

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.