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 wou...
  • V-lianl-msft's avatar
    4 years ago

    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.