< Back

Get-AzureSubscription

Wed Jan 30, 2019 5:41 pm

NAME Get-AzureSubscription



SYNOPSIS

Gets Azure subscriptions in the user accounts.





SYNTAX

Get-AzureSubscription [[-SubscriptionName] <String>] [-ExtendedDetails] [-SubscriptionDataFile <String>] [<CommonParameters>]



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



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





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 .7.2 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 [<SwitchParameter>]

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.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Default [<SwitchParameter>]

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.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-ExtendedDetails [<SwitchParameter>]

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



Required? false

Position? named

Default value

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.



Required? false

Position? named

Default value

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.



Required? false

Position? 1

Default value

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS

None



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





OUTPUTS

Microsoft.WindowsAzure.Commands.Utilities.Common.AzureSubscription



By default, Get-AzureSubscription returns a AzureSubscription object.



Microsoft.WindowsAzure.Commands.Utilities.Common.SubscriptionDataExtended



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





NOTES





Keywords: azure, azuresm, servicemanagement, management, service, utilities



Example 1: Get all subscriptions



C:\\PS>Get-AzureSubscription



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

Example 2: Get a subscription by name



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



This command gets only the "MyProdSubsciption" subscription.

Example 3: Get the default subscription



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

ContosoEngineering



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.

Example 4: Get the current subscription



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: Get quota properties



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



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.



RELATED LINKS

Online Version: http://go.microsoft.com/fwlink/?LinkID=397623

Add-AzureAccount

Get-AzurePublishSettingsFile

Import-AzurePublishSettingsFile

Remove-AzureSubscription

Select-AzureSubscription

Set-AzureSubscription