Get-AzSubscription

This cmdlet retrieves information about the Azure subscriptions accessible to the user. It's a fundamental command for managing and viewing your Azure resources.

Parameters

Name Type Description
-SubscriptionId String Specifies the ID of the subscription to retrieve. If omitted, all accessible subscriptions are returned.
-TenantId String Specifies the ID of the tenant that the subscription belongs to.
-ErrorAction ActionPreference Specifies how to handle errors. Allowed values are Continue, Ignore, Inquire, SilentlyContinue, Stop, and Suspend.
-ErrorVariable String Specifies a variable in which to store error messages.
-OutBuffer String Specifies that the output of the command is buffered.
-OutVariable String Specifies that the output of the command is added to a variable.
-WarningAction ActionPreference Specifies how to handle warnings. Allowed values are Continue, Ignore, Inquire, SilentlyContinue, Stop, and Suspend.
-WarningVariable String Specifies a variable in which to store warning messages.
-Confirm SwitchParameter Prompts you for confirmation before running the cmdlet.
-WhatIf SwitchParameter Shows what would happen if the cmdlet runs. The cmdlet is not run.

Examples

Get all Azure subscriptions for the current user.
PS > Get-AzSubscription
Get a specific Azure subscription by its ID.
PS > Get-AzSubscription -SubscriptionId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
Get subscriptions belonging to a specific tenant.
PS > Get-AzSubscription -TenantId "yyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy"
Output the subscription information to a variable named $subscriptions.
PS > Get-AzSubscription -OutVariable subscriptions