Edit

Share via


Get-AzureSubscription

Gets Azure subscriptions in Azure account.

Note

The cmdlets referenced in this documentation are for managing legacy Azure resources that use Azure Service Manager (ASM) APIs. This legacy PowerShell module isn't recommended when creating new resources since ASM is scheduled for retirement. For more information, see Azure Service Manager retirement.

The Az PowerShell module is the recommended PowerShell module for managing Azure Resource Manager (ARM) resources with PowerShell.

Syntax

ByName (Default)

Get-AzureSubscription
    [-SubscriptionName <String>]
    [-ExtendedDetails]
    [-Profile <AzureSMProfile>]
    [<CommonParameters>]

ById

Get-AzureSubscription
    [-SubscriptionId <String>]
    [-ExtendedDetails]
    [-Profile <AzureSMProfile>]
    [<CommonParameters>]

Default

Get-AzureSubscription
    [-Default]
    [-ExtendedDetails]
    [-Profile <AzureSMProfile>]
    [<CommonParameters>]

Current

Get-AzureSubscription
    [-Current]
    [-ExtendedDetails]
    [-Profile <AzureSMProfile>]
    [<CommonParameters>]

Description

The Get-AzureSubscription cmdlet gets the subscriptions in your Azure account. You can use this cmdlet to get information about the subscription and to pipe the subscription to other cmdlets.

Get-AzureSubscription requires access to your Azure accounts. Before you run Get-AzureSubscription, you must run the Add-AzureAccount cmdlet or the cmdlets that download and install a publish settings file (Get-AzurePublishSettingsFile, Import-AzurePublishSettingsFile.

This topic describes the cmdlet in the 0.8.10 version of the Microsoft Azure PowerShell module. To get the version of the module you're using, in the Azure PowerShell console, type (Get-Module -Name Azure).Version.

Examples

Example 1: Get all subscriptions

C:\PS>Get-AzureSubscription

This command gets all subscriptions in the account.

Example 2: Get a subscription by name

C:\PS>Get-AzureSubscription -SubscriptionName "MyProdSubscription"

This command gets only the "MyProdSubscription" subscription.

Example 3: Get the default subscription

C:\PS>(Get-AzureSubscription -Default).SubscriptionName

This command gets only the name of the default subscription. The command first gets the subscription and then uses the dot method to get the SubscriptionName property of the subscription.

Example 4: Get selected subscription properties

C:\PS>Get-AzureSubscription -Current | Format-List -Property SubscriptionName, Certificate

This command returns a list with the name and certificate of the current subscription. It uses a Get-AzureSubscription command to get the current subscription. Then it pipes the subscription to a Format-List command that displays the selected properties in a list.

Example 5: Use an alternate subscription data file

C:\PS>Get-AzureSubscription -SubscriptionDataFile "C:\Temp\MySubscriptions.xml"

This command gets subscriptions from the C:\Temp\MySubscriptions.xml subscription data file. Use the SubscriptionDataFile parameter if you specified an alternate subscription data file when you ran the Add-AzureAccount or Import-PublishSettingsFile cmdlets.

Parameters

-Current

Gets only the current subscription, that is, the subscription designated as "current." By default, Get-AzureSubscription gets all subscriptions in your Azure accounts. To designate a subscription as "current," use the Current parameter of the Select-AzureSubscription cmdlet.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

Current
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Default

Gets only the default subscription, that is, the subscription designated as "default." By default, Get-AzureSubscription gets all subscriptions in your Azure accounts. To designate a subscription as "default," use the Default parameter of the Select-AzureSubscription cmdlet.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

Default
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ExtendedDetails

Returns quota information for the subscription, in addition to the standard settings.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Profile

Specifies the Azure profile from which this cmdlet reads. If you do not specify a profile, this cmdlet reads from the local default profile.

Parameter properties

Type:AzureSMProfile
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-SubscriptionId

The Get-AzureSubscription cmdlet gets the subscriptions in your Azure account. You can use this cmdlet to get information about the subscription and to pipe the subscription to other cmdlets.

Get-AzureSubscription requires access to your Azure accounts. Before you run Get-AzureSubscription, you must run the Add-AzureAccount cmdlet or the cmdlets that download and install a publish settings file (Get-AzurePublishSettingsFile, Import-AzurePublishSettingsFile.

This topic describes the cmdlet in the 0.8.10 version of the Microsoft Azure PowerShell module. To get the version of the module you're using, in the Azure PowerShell console, type (Get-Module -Name Azure).Version.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False
Aliases:Id

Parameter sets

ById
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-SubscriptionName

Gets only the specified subscription. Enter the subscription name. The value is case-sensitive. Wildcard characters are not supported. By default, Get-AzureSubscription gets all subscriptions in your Azure accounts.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False
Aliases:Name

Parameter sets

ByName
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

None

You can pipe input to the SubscriptionName property by name, but not by value.

Outputs

Microsoft.WindowsAzure.Commands.Utilities.Common.WindowsAzureSubscription

Notes

  • Get-AzureSubscription gets data from the subscription data file that the Add-AzureAccount and Import-PublishSettingsFile cmdlets create.