none
PowerShell help RRS feed

  • Question

  • Hello, 

    i have approx 500 PBI workspaces and out of the 500, would like to add a service account as the admin to approx 200 of those work spaces. I have the ID's of all the workspaces i need. 

    I have started to write a script, as below - but i keep getting an error saying that it cannot convert Syste.Object to the Syste.Guid required yb parameter Id. 

    I presume the $workspaces variable is being passed as long string into the Add-PowerBIWorspace user. 

    How do i correct this so that the foreach loops loops through every given ID and add the given user as an Admin. 

    my test code below. 

    Connect-PowerBIServiceAccount 

    $workspaces = "5d92f592-cvb4-89q8-a213-lf384ah90953", "2455b47p-3d8b-470f-a920-465h6ga95ab2"
    Foreach ($workspace in $workspaces)
    {
    Add-PowerBIWorkspaceUser -Scope Individual -Id $workspaces -UserEmailAddress testuser1@mydomain.onmicrosoft.com -AccessRight Admin

    }

    Thanks in advance. 

    Monday, June 15, 2020 1:39 PM

Answers