Forum Discussion

mr_method's avatar
mr_method
Regular Visitor
3 years ago
Solved

Error when using PowerShell to add AD Security Group to Workspace.

Using PowerShell to add AD Security Group to Workspace.
Wednesday

HI All,
     I am trying Add Active Directory Security Group to workspace using PowerShell. 
I can do it manually ( I am Global Admin on the tenant)
I can add specific user using the PowerShell cmdlet
# Authenticate to the Power BI service
Connect-PowerBIServiceAccount
"ADD-PowerBIWorkspaceUser -id <workspaceId> -UserEmailAddress - <UserPrincipalName> - AccessRight <AccessRight>" 
The issue is when I try using th same command to Add AD Security Group (Email enabled) I get an error saying 

Here is the cmdlet.
# Authenticate to the Power BI service
Connect-PowerBIServiceAccount
Add-PowerBIWorkspaceUser -Scope Organization -Id  <WorkspaceId> -Identifier <AD Group GUI> -AccessRight Viewer -PrincipalType Group
And Here is the error I am getting
Add-PowerBIWorkspaceUser: Operation returned an invalid status code 'BadRequest'
and using the Resolve-PowerBIError cmdlet 
I get "InvalidRequest","message":"Parameter PrincipalType or Identifier is missing or invalid"
I am wondering if there is something I am missing.
P.S. On V2 workspace. Using connect-PowerBIServiceAccount to connect to the powerbi.com.

Thanks in advance.

  • Hi , mr_method

    I use your cmdlet in PowerShell and return the same error:

    The warning message "Only preview workspaces are supported when -Scope Organization is specified" indicates that the workspace you are trying to add the user to is not a preview workspace.

    The -Scope Organization parameter is used to specify that the workspace is an organizational workspace, which is a new type of workspace that is currently in preview. Preview workspaces are not yet generally available and are subject to change.

     

    For now , you can just omit the -Scope Organization parameter to test :
    Add-PowerBIWorkspaceUser -Id "workspace ID" -Identifier "Group Object ID" -AccessRight Viewer -PrincipalType Group

    And the Group Object ID you can get in Azure Portal:

    And then you can add it in workspace successfully:

     

     

    Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

     

    Best Regards,

    Aniya Zhang

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

1 Reply

  • Hi , mr_method

    I use your cmdlet in PowerShell and return the same error:

    The warning message "Only preview workspaces are supported when -Scope Organization is specified" indicates that the workspace you are trying to add the user to is not a preview workspace.

    The -Scope Organization parameter is used to specify that the workspace is an organizational workspace, which is a new type of workspace that is currently in preview. Preview workspaces are not yet generally available and are subject to change.

     

    For now , you can just omit the -Scope Organization parameter to test :
    Add-PowerBIWorkspaceUser -Id "workspace ID" -Identifier "Group Object ID" -AccessRight Viewer -PrincipalType Group

    And the Group Object ID you can get in Azure Portal:

    And then you can add it in workspace successfully:

     

     

    Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

     

    Best Regards,

    Aniya Zhang

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