Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

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 1
v-xicai
Community Support
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.

90.png

 

 

 

 

 

 

 

 

 

 

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.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.