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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply

Get Workspace By Capacity Name

Is any way or rest API to get Workspace list by Capacity Name attached ..

 

TIA 

Paritosh Mishra 

2 ACCEPTED SOLUTIONS
lbendlin
Super User
Super User

Capacity names are meaningless.  Depending on your tenant admin rights you can either see all workspaces, or you can see the workspaces that you are a member of.

 

Groups - Get Groups (Power BI Power BI REST APIs) | Microsoft Docs

 

View solution in original post

lbendlin
Super User
Super User

 

 

# Calls the Active Directory Authentication Library (ADAL) to authenticate against AAD
function GetAuthToken
{
    if(-not (Get-Module AzureRm.Profile)) {
        Import-Module AzureRm.Profile
    }
    $clientId = "your client id here"
    $redirectUri = "urn:ietf:wg:oauth:2.0:oob"
    $resourceAppIdURI = "https://analysis.windows.net/powerbi/api"
    $authority = "https://login.microsoftonline.com/common/oauth2/authorize";
    $authContext = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext" -ArgumentList $authority
    $authResult = $authContext.AcquireToken($resourceAppIdURI, $clientId, $redirectUri, "Auto")
    return $authResult
}

# Get the auth token from AAD
$token = GetAuthToken

# Building Rest API header with authorization token
$authHeader = @{
    'Content-Type'='application/json'
    'Authorization'=$token.CreateAuthorizationHeader()
}

# get workspaces with capacityId where present

$uri = "https://api.powerbi.com/v1.0/myorg/groups"
$v = (Invoke-RestMethod -Uri $uri –Headers $authHeader –Method GET).value 
$v | Select id,isReadOnly,isOnDedicatedCapacity,capacityId,name | Format-Table -AutoSize

 

 

View solution in original post

5 REPLIES 5
lbendlin
Super User
Super User

 

 

# Calls the Active Directory Authentication Library (ADAL) to authenticate against AAD
function GetAuthToken
{
    if(-not (Get-Module AzureRm.Profile)) {
        Import-Module AzureRm.Profile
    }
    $clientId = "your client id here"
    $redirectUri = "urn:ietf:wg:oauth:2.0:oob"
    $resourceAppIdURI = "https://analysis.windows.net/powerbi/api"
    $authority = "https://login.microsoftonline.com/common/oauth2/authorize";
    $authContext = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext" -ArgumentList $authority
    $authResult = $authContext.AcquireToken($resourceAppIdURI, $clientId, $redirectUri, "Auto")
    return $authResult
}

# Get the auth token from AAD
$token = GetAuthToken

# Building Rest API header with authorization token
$authHeader = @{
    'Content-Type'='application/json'
    'Authorization'=$token.CreateAuthorizationHeader()
}

# get workspaces with capacityId where present

$uri = "https://api.powerbi.com/v1.0/myorg/groups"
$v = (Invoke-RestMethod -Uri $uri –Headers $authHeader –Method GET).value 
$v | Select id,isReadOnly,isOnDedicatedCapacity,capacityId,name | Format-Table -AutoSize

 

 

lbendlin
Super User
Super User

Did you mean Postmates?

As far as I can see the response is identical.

Sorry for typo   mistakes.I have edited my previous msg  

lbendlin
Super User
Super User

Capacity names are meaningless.  Depending on your tenant admin rights you can either see all workspaces, or you can see the workspaces that you are a member of.

 

Groups - Get Groups (Power BI Power BI REST APIs) | Microsoft Docs

 

When this API "GET https://api.powerbi.com/v1.0/myorg/groups"  runs by powershell its return  4 filed 

 

id                                                         isReadOnly    isOnDedicatedCapacity   name
-- ---------- --------------------- ----
5bbca568-2881-4628-a28a-1d2245aea88c    False    False                 PowerbiAccessGroup
5e68fde1-5a6b-467b-af41-9775cc32166e      False   True                  condecouserdevt011

When  same API on "Postman" its resposd body is 


{
    "@odata.count"16,
    "value": [
        {
            "id""5bbca568-2881-4628-a28a-1d2245aea88c",
            "isReadOnly"false,
            "isOnDedicatedCapacity"false,
            "name""PowerbiAccessGroup"
        },
        {
            "id": "5e68fde1-5a6b-467b-af41-9775cc32166e",
            "isReadOnly": false,
            "isOnDedicatedCapacity": true,
            "capacityId": "D42A91A3-6A85-4290-8291-6ECFEC4BAC2B",
            "name": "condecouserdevt011"
        }
]
}
This show "Capacity Id" field  .How come ??/
How I get same response on powershell , as I run powershell on  our pipeline >>>>

Its Postman .Postman response have capacityID where as powershell show only "id  isReadOnly isOnDedicatedCapacity  name"

 

 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors