Forum Discussion
unassign capacity via Power shell script and error returned
I tried to run script to unassign a workspace from capacity based on the article below. but it returned an error without much insight. please assist
https://docs.microsoft.com/en-us/rest/api/power-bi/capacities/groups_assigntocapacity
Script:
Connect-PowerBIServiceAccount
$id = "4f0bd27b-96ca-4508-9d6c-f4c3a9cf1602"
#$Url = "https://api.powerbi.com/v1.0/myorg/groups/$id/AssignToCapacity"
#$url = "groups/$id/AssignToCapacity"
$url = "groups/4f0bd27b-96ca-4508-9d6c-f4c3a9cf1602/AssignToCapacity"
$body = @{"capacityId"="00000000-0000-0000-0000-000000000000"}
$re = Invoke-PowerBIRestMethod -Url $Url -Method Post -Body $body
$re
error message:
Invoke-PowerBIRestMethod : One or more errors occurred.
At C:\pb\assign-pb.ps1:12 char:7
+ $re = Invoke-PowerBIRestMethod -Url $Url -Method Post -Body $body
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (Microsoft.Power...werBIRestMethod:InvokePowerBIRestMethod) [Invoke-PowerBIRestMethod], AggregateException
+ FullyQualifiedErrorId : One or more errors occurred.,Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod
1 Reply
- v-xicai
Community Support
Hi Anonymous ,
You may refer to the similar case: Power Shell Invoke-PowerBIRestMethod -Method Post failing .
For further analysis, could you please show us your scripts? Do mask sensitive data before uploading.
From the article, we know that to unassign from capacity, use Empty Guid (00000000-0000-0000-0000-000000000000) to capacityId.
Workspace admins can remove a workspace from a capacity (to shared capacity) without requiring assignment permission in workspace setting page. See more :https://docs.microsoft.com/en-us/power-bi/service-premium-capacity-manage#assigning-workspaces-to-capacities.
Best Regards,
Amy
Community Support Team _ Amy
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.