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