Quantcast
Channel: Azure Active Directory forum
Viewing all articles
Browse latest Browse all 16000

How can I specify a directory (or all directories accessible) to query over REST API?

$
0
0

Using the  PowerShell Azure module, it returns all subscriptions to which I have access, or "x" number of subscriptions.

Connect-AzureRmAccount

(Get-AzureRmSubscription).count ### = 'x'


Using PowerShell to access the REST API, it only returns the subscriptions in my default directory; or a count of "x-y".  How can I either, have the API return all the subscriptions accessible by the account, or let me specify which directory I want to query?

$azureRmProfile = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile

$azureRmProfileClient = New-Object Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient($azureRmProfile)

$azureRmContext = Get-AzureRmContext

$token = $azureRmProfileClient.AcquireAccessToken($azureRmContext.Subscription.TenantId)

$subsApi= 'https://management.azure.com/subscriptions?api-version=2016-06-01'

$headers = @{"Authorization"="bearer "+ $token.AccessToken} $subs = Invoke-RestMethod -Uri $subsApi -Headers $headers ($subs.value).count ### returns "x-y" where y > 0





Viewing all articles
Browse latest Browse all 16000

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>