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
JernejaPi
Frequent Visitor

List of all reports and dashboards for each workspace in my organization

Hi all,

I am trying to get a list of all reports and dashbards for each workspace in my organization using code: 

 

$Workspaces = Get-PowerBIWorkspace -Scope Organization | Where {($_.State -eq "Active")}

$Reports = $Workspaces | ForEach-Object {
  $group = $_
  Get-PowerBIReport -WorkspaceId $group.Id | ForEach-Object {
    $report = $_
    New-Object -TypeName PSObject -Property @{
      WorkspaceId = $group.Id
      WorkspaceName = $group.Name
      Id = $report.id
      Name = $report.Name
      WebUrl = $report.WebUrl
      EmbedUrl = $report.EmbedUrl
      DatasetId = $report.DatasetId
    }
  }
}

 

using admin account. As the result I get a list of 4 reports (expected nr of reports is around 200). 

Then I tried to do the same thing using API:

 

#Create the Table Object
$allMembers = New-Object system.Data.DataTable "All members in all groups"

#define columns for table
$col1 = New-Object system.Data.DataColumn Id,([string])
$col2 = New-Object system.Data.DataColumn Name,([string])
$col3 = New-Object system.Data.DataColumn Email,([string])
$col4 = New-Object system.Data.DataColumn AccessRight,([string])

#Add the columns to table
$allMembers.columns.add($col1)
$allMembers.columns.add($col2)
$allMembers.columns.add($col3)
$allMembers.columns.add($col4)

foreach ($item in $ListOfWorkspaces){
  $a = ‘admin/groups/' + $item.id + '/users’
  $myMembers = Invoke-PowerBIRestMethod -Url $a -Method Get | ConvertFrom-Json
  foreach ($Ritem in $myMembers.value){    

#create a row
    $row = $allMembers.NewRow()    

#Enter data in the row
    $row.Id = $Item.id
    $row.Name = $Item.name
    $row.Email = $RItem.emailAddress
    $row.AccessRight = $RItem.groupUserAccessRight    

    #Add the row to the table
    $allMembers.Rows.Add($row)
  }
}

$allMembers

And the result is an error:

BUGBUG

 

Best, Jerneja

0 REPLIES 0

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.