Inventory Azure subscriptions
Documentation: Microsoft Learn
Get-AzSubscription lists the subscriptions the signed-in identity can see in the current tenant, and the projection keeps name, ID, tenant ID and State.
The script
Script reader
Inspect before you run
Inspect the script below. It does not run in this browser.
Inspection only — no command has run.
Show reference output
Inspect this example’s structure
Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.
Get-AzSubscription | Select-Object Name,Id,State,IsDefault- Stage 1Get-AzSubscription
Positional values or no named parameters - Stage 2Select-Object
Positional values or no named parameters
How it works
Get-AzSubscription lists the subscriptions the signed-in identity can see in the current tenant, and the projection keeps name, ID, tenant ID and State. Use Get-AzContext to see which subscription subsequent Az commands will target.
Adapting it
Follow this with Set-AzContext -SubscriptionId to move the session deliberately instead of relying on whichever subscription the login happened to select.
Requirements
Az.Accounts with an active Connect-AzAccount session.
If the result is unexpected
An Azure subscription is missing from the list.
The signed-in identity may lack access, or the context may belong to another tenant or cloud.
- Inspect the Azure account context and compare a known subscription identifier with the access granted to that identity.
Validate the result
The intended subscription is returned under the expected tenant.
Keep the check reliable
Use explicit tenant and subscription identifiers in scheduled reports.