Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

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