Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

[Powershell] Get workspaces for specified group of users

Hello,

 

I am looking for some solution that allows me to find all workspaces where a specified group of users has access. So first, I prepare the list of such users in the variable, and then I would like to search by iterating workspaces to find if they have access. Here is the example list of my users:

 

$Users = Get-AzureADUser -all $true | Where-Object {$_.Department -like "*XYZ*"}

 

 

How would you find all workspaces where they have access?

Thank you very much for any help!

Regards

  • Hi Anonymous ,

     

    As far as I am concerned,You can get a list of users who have access to the App Workspace, but you will not be able to find users who have access via Workspace.

    You can use the following Power BI REST API to find out details in Workspaces then loop through all your app workspaces to find the details:

    https://docs.microsoft.com/en-us/powershell/module/microsoftpowerbimgmt.workspaces/get-powerbiworkspace?view=powerbi-ps 

    Hope this sample script may help you:

    Login-PowerBIServiceAccount
    Get-PowerBIWorkspace -Scope Organization -All |
    ForEach-Object {
    $Workspace = $_.name
    $WorkspaceId = $_.Id
    $IsOnDedicatedCapacity = $_.isOnDedicatedCapacity
    $State = $_.state
    $Type = $_.type
    $Capacityid = $_.CapacityId
    foreach ($User in $_.Users) {
    [PSCustomObject]@{
    Workspace = $Workspace
    WorkspaceId = $WorkspaceId
    IsOnDedicatedCapacity = $IsOnDedicatedCapacity
    State = $State
    Type = $Type
    CapcityId = $Capacityid
    User = $User.accessright
    Identifier =$user.Identifier}
    }} | Export-CSV "C:\xxxxx\Workspace-UserAccess.csv" -NoTypeInformation

     

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

2 Replies

  • Might be easier to ask your tenant admin for the respective inventory logs (WorkspacesUsers).

  • V-lianl-msft's avatar
    V-lianl-msft
    Community Support

    Hi Anonymous ,

     

    As far as I am concerned,You can get a list of users who have access to the App Workspace, but you will not be able to find users who have access via Workspace.

    You can use the following Power BI REST API to find out details in Workspaces then loop through all your app workspaces to find the details:

    https://docs.microsoft.com/en-us/powershell/module/microsoftpowerbimgmt.workspaces/get-powerbiworkspace?view=powerbi-ps 

    Hope this sample script may help you:

    Login-PowerBIServiceAccount
    Get-PowerBIWorkspace -Scope Organization -All |
    ForEach-Object {
    $Workspace = $_.name
    $WorkspaceId = $_.Id
    $IsOnDedicatedCapacity = $_.isOnDedicatedCapacity
    $State = $_.state
    $Type = $_.type
    $Capacityid = $_.CapacityId
    foreach ($User in $_.Users) {
    [PSCustomObject]@{
    Workspace = $Workspace
    WorkspaceId = $WorkspaceId
    IsOnDedicatedCapacity = $IsOnDedicatedCapacity
    State = $State
    Type = $Type
    CapcityId = $Capacityid
    User = $User.accessright
    Identifier =$user.Identifier}
    }} | Export-CSV "C:\xxxxx\Workspace-UserAccess.csv" -NoTypeInformation

     

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