Get-AzureRmSubscription

Gets subscriptions that the current account can access.

Syntax

Get-AzureRmSubscription
   [-SubscriptionId <String>]
   [-TenantId <String>]
   [<CommonParameters>]
Get-AzureRmSubscription
   [-SubscriptionName <String>]
   [-TenantId <String>]
   [<CommonParameters>]

Description

The Get-AzureRmSubscription cmdlet gets the subscription ID, subscription name, and home tenant for Azure subscriptions that the current account can access.

Examples

Example 1: Get all subscriptions for a specific tenant

PS C:\>Get-AzureRmSubscription -TenantId 'xxxx-xxxx-xxxx-xxxx'
SubscriptionId: yyyy-yyyy-yyyy-yyyy
TenantId: xxxx-xxxx-xxxx-xxxx
Subscription Name: Contoso Subscription 1


SubscriptionId: yyyy-yyyy-yyyy-yyyy
TenantId: xxxx-xxxx-xxxx-xxxxSubscription Name: Contoso Subscription 2

This cmdlet displays the subscriptions in the given tenant that are authorized for the current account. These examples use placeholder values for the tenant ID and the subscription ID.

Example 2: Get all subscriptions in the current tenant

PS C:\>Get-AzureRmSubscription
SubscriptionId: yyyy-yyyy-yyyy-yyyy
TenantId: xxxx-xxxx-xxxx-xxxx
Subscription Name: Contoso Subscription 1


SubscriptionId: yyyy-yyyy-yyyy-yyyy
TenantId: xxxx-xxxx-xxxx-xxxx
Subscription Name: Contoso Subscription 2

This command gets all subscriptions in the current tenant that are authorized for the current user.

Example 3: Change the current context to use a specific subscription

PS C:\>Get-AzureRmSubscription -SubscriptionId 'xxxx-xxxx-xxxx-xxxx' -TenantId 'yyyy-yyyy-yyyy-yyyy' | Set-AzureRmContext
SubscriptionId: xxxx-xxxx-xxxx-xxxx
TenantId: yyyy-yyyy-yyyy-yyyy
Subscription Name: Contoso Subscription 1

This command gets the specified subscription, and then passes it to the Set-AzureRmContext cmdlet by using the pipeline operator. That cmdlet sets the current context to use that subscription. By default, all subsequent cmdlets in this session use the specified subscription.

Optional Parameters

-SubscriptionId

Specifies the ID of the subscription to get.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-SubscriptionName

Specifies the name of the subscription to get.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-TenantId

Specifies the ID of the tenant that contains subscriptions to get.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False