Forum Discussion

AUaero's avatar
AUaero
Responsive Resident
6 years ago

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