Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago

get-powerbiworkspace permession

Hi 

 

I'm tryinf to get List of Power BI tenant workspaces with members. I tried to run the script below but keep getting unauthorized to run this task. My user has PowerBI admin and assigned PowerBI Service Admin as well . Do I need more permession please ?

 

Best regards

Sam

 

-----------------------------------------------------------

 

 

Import-Module MicrosoftPowerBIMgmt

 

$password = "xxxxxxxx" | ConvertTo-SecureString -asPlainText -Force

$username = [email protected]

$credential = New-Object System.Management.Automation.PSCredential($username, $password)

 

Connect-PowerBIServiceAccount -Credential $credential

 

$Session = New-PSSession -ConfigurationName Microsoft.Exchange `

    -ConnectionUri https://outlook.office365.com/powershell-liveid/ `

    -Credential $credential `

    -Authentication Basic `

    -AllowRedirection

 

Import-PSSession $Session

 

$Groups = Get-PowerBIWorkspace #-Scope Organization

$Groups | ForEach-Object {

    $group = $_

    Get-UnifiedGroupLinks -Identity $group.Name -LinkType Members -ResultSize Unlimited | ForEach-Object {

        $member = $_

        New-Object -TypeName PSObject -Property @{

            Member = $member.Name

            Group = $group.Name

        }

    }

} | Export-CSV "D:\\PowerBIGroupMembers.csv" -NoTypeInformation -Encoding UTF8

 

Remove-PSSession $Session

 

Disconnect-PowerBIServiceAccount

 

 

 

5 Replies

  • v-zhangti's avatar
    v-zhangti
    Community Support

    Hi, Anonymous 

     

    You can also try the following to get a list of members of the Power BI tenant workspace.

     

    Try to use PowerShell:

    Connect-PowerBIServiceAccount
    
    $Workspaces = Get-PowerBIWorkspace -Scope Organization -All 
    
    $Workspaces | 
        ForEach-Object {
            $Workspace = $_.name
            foreach ($User in $_.Users) {
                [PSCustomObject]@{
                    Workspace = $Workspace
                    User      = $User.UserPrincipalName
                }
            }
        } | Export-CSV "D:\\PowerBIGroupMembers.csv" -NoTypeInformation -Encoding UTF8

     

    If the script above doesn't display users, try this:

    Connect-PowerBIServiceAccount
    $Workspaces = Get-PowerBIWorkspace -Scope Organization -All 
    $Workspaces | 
        ForEach-Object {
            $Workspace = $_.name
            foreach ($User in $_.Users) {
                [PSCustomObject]@{
                    Workspace = $Workspace
                    User      = $User.Identifier 
                }
            }
        } | Export-CSV "D:\\PowerBIGroupMembers.csv" -NoTypeInformation -Encoding UTF8

     

    Best Regards,

    Community Support Team _Charlotte

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi 

       

      Thank you for your reply

       

      The problem is im getting "Unauthorized" when i try to run :

       

       Get-PowerBIWorkspace -Scope Organization -All

       

      I have PowerBI admin role and also PowerBI service admin account .. so do i miss any more permession to run this command please ?

       

      I ran your script and got this error :

       

      Bets regards

      Sam