PowerBI Query - Trying to list workspaces and users

Welcome Forums General PowerShell Q&A PowerBI Query - Trying to list workspaces and users

This topic contains 7 replies, has 2 voices, and was last updated by

 
Participant
1 month, 1 week ago.

  • Author
    Posts
  • #163719

    Participant
    Topics: 9
    Replies: 14
    Points: 108
    Rank: Participant

    I made several attempts to list the active workspaces and their users in a row-style output.  I have the following query:

    $ActiveWorkspaces = Get-PowerBIWorkspace -Scope Organization -All | Where {($_.Type -eq "Workspace") -and ($_.State -eq "Active")} 

    When you run the query, there are several workspaces listed with their properties and then the Users property has subproperties of AccessRight and UserPrincipalName.  I'd like to line up the workspace name and user properties.

    Any suggestions?

    Thanks,

    Frank

     

  • #163740

    Participant
    Topics: 9
    Replies: 14
    Points: 108
    Rank: Participant

    I forgot to add this part:

    $ActiveWorkspaces | Select-Object name, users

    This returns the users grouped with the workspace name:

    workspace1 {user1@, user2@, user3@}
    
    workspace2 {user1@, user2@}

    I would like to list the workspace and user on separate lines?

  • #163785

    Participant
    Topics: 1
    Replies: 1530
    Points: 2,591
    Helping Hand
    Rank: Community Hero

    Hmmm ... I'm not quite sure if I got what you mean ... did you try Format-List?

  • #163878

    Participant
    Topics: 9
    Replies: 14
    Points: 108
    Rank: Participant

    Hi, sorry.  I should've been clearer.  I want the output to look like the following:

    workspace1 user1
    
    workspace1 user2
    
    workspace1 user3
    
    workspace2 user1
    
    workspace2 user2

    I want to list the workspace and user on their own lines.

    Hope this helps!

  • #163899

    Participant
    Topics: 1
    Replies: 1530
    Points: 2,591
    Helping Hand
    Rank: Community Hero

    Ah ... you could use nested loops to achieve this ...

    $ActiveWorkspaces | 
        ForEach-Object {
            $Workspace = $_.name
            foreach ($User in $_.Users) {
                [PSCustomObject]@{
                    Workspace = $Workspace
                    User      = $User
                }
            }
        }
    

    ... of course ... untested 😉

    • #170011

      Participant
      Topics: 9
      Replies: 14
      Points: 108
      Rank: Participant

      That's pretty much what I need, but the Users seemed to be a subproperty of the main object:

      Users :
      AccessRight UserPrincipalName
      ———– —————–
      Admin user1

      If you run just the $activeworkspaces variable without the loop, it returns it as 'Users' with its own sub-properties of 'AccessRight' and 'UserPrincipalName'.  The 'UserPrincipalName' is what I need to be listed with the workspace name.

       

       

       

  • #170035

    Participant
    Topics: 1
    Replies: 1530
    Points: 2,591
    Helping Hand
    Rank: Community Hero

    Hmmm ... so you are lucky with it or do you need something more? Did you get what you need, finally? You reply is not quite clear about that.

    If you need a subproperty of the variable $User with the the UserPrincipalName you simply use the "dot notation" ...

    $User.UserPrincipalName
    • #170404

      Participant
      Topics: 9
      Replies: 14
      Points: 108
      Rank: Participant

      That was it!  Thx for all of your help!

You must be logged in to reply to this topic.