Get-AzureSubscription

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Get-AzureSubscription

Gets Azure subscriptions in the user accounts.

Syntax

Parameter Set: ByName
Get-AzureSubscription [[-SubscriptionName] <String> ] [-ExtendedDetails] [-SubscriptionDataFile <String> ] [ <CommonParameters>]

Parameter Set: Current
Get-AzureSubscription [-Current] [-ExtendedDetails] [-SubscriptionDataFile <String> ] [ <CommonParameters>]

Parameter Set: Default
Get-AzureSubscription [-Default] [-ExtendedDetails] [-SubscriptionDataFile <String> ] [ <CommonParameters>]

Detailed Description

The Get-AzureSubscription cmdlet gets the subscriptions in your Azure accounts. 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.1 version of the Microsoft Azure PowerShell module. To find out the version of the module you're using, from the Azure PowerShell console, type (get-module azure).version.

Parameters

-Current

Gets only the current subscription. By default, Get-AzureSubscription gets all subscriptions in your Azure accounts.

You can designate "current" and "default" subscriptions. The "current subscription" is used by default in the current Windows PowerShell session. The "default subscription" is used by default for all Windows PowerShell sessions. The "current subscription" label lets you specify a subscription to be used by default for the current session without changing the "default subscription" for all other sessions.

To designate subscriptions as "current" and "default," use the Select-AzureSubscription cmdlet.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Default

Gets only the default subscription. By default, Get-AzureSubscription gets all subscriptions in your Azure accounts.

The "default subscription" is the subscription that is used by default for all Windows PowerShell sessions. To use a different subscription as the default only for the current session, set a subscription to "Current". To designate subscriptions as "current" and "default," use the Select-AzureSubscription cmdlet.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ExtendedDetails

Returns quota properties of the subscription, in addition to the standard properties.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-SubscriptionDataFile<String>

Gets a subscription from an alternate subscription data file. Use this parameter if you used the SubscriptionDataFile parameter of Add-AzureAccount or Import-PublishSettingsFile to specify an alternate location for the subscription data file. By default, your subscription data file is saved in your roaming user profile.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-SubscriptionName<String>

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.

Aliases

none

Required?

false

Position?

1

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see  about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216).

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • None

    You can pipe input to this cmdlet by property name, but not by value.

Outputs

The output type is the type of the objects that the cmdlet emits.

  • Microsoft.WindowsAzure.Commands.Utilities.Common.WindowsAzureSubscription

    By default, Get-AzureSubscription returns a WindowsAzureSubscription object.

  • Microsoft.WindowsAzure.Commands.Utilities.Common.SubscriptionDataExtended

    When you use the ExtendedDetails parameter, Get-AzureSubscription returns a SubscriptionDataExtended object.

Examples

Example 1: Get all subscriptions

This command gets all subscriptions that are available to Windows PowerShell.

C:\PS>Get-AzureSubscription

Example 2: Get a subscription by name

This command gets only the "MyProdSubsciption" subscription.

C:\PS>Get-AzureSubscription –SubscriptionName MyProdSubscription

Example 3: Get the default subscription

This command gets 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.

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

Example 4: Get the current subscription

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.

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

Example 5: Get quota properties

This command gets all properties, included quota properties, of the subscriptions in 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.

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

Add-AzureAccount

Get-AzurePublishSettingsFile

Import-AzurePublishSettingsFile

Remove-AzureSubscription

Select-AzureSubscription

Set-AzureSubscription