Select-AzureSubscription

Changes the current and default Azure subscriptions.

Note

The cmdlets referenced in this documentation are for managing legacy Azure resources that use Service Management APIs. See the Az PowerShell module for cmdlets to manage Azure Resource Manager resources.

Syntax

Select-AzureSubscription
      -SubscriptionName <String>
      [-Account <String>]
      [-Current]
      [-PassThru]
      [-Profile <AzureSMProfile>]
      [<CommonParameters>]
Select-AzureSubscription
      -SubscriptionName <String>
      [-Account <String>]
      [-Default]
      [-PassThru]
      [-Profile <AzureSMProfile>]
      [<CommonParameters>]
Select-AzureSubscription
      -SubscriptionId <String>
      [-Account <String>]
      [-Current]
      [-PassThru]
      [-Profile <AzureSMProfile>]
      [<CommonParameters>]
Select-AzureSubscription
      -SubscriptionId <String>
      [-Account <String>]
      [-Default]
      [-PassThru]
      [-Profile <AzureSMProfile>]
      [<CommonParameters>]
Select-AzureSubscription
      [-Account <String>]
      [-NoCurrent]
      [-PassThru]
      [-Profile <AzureSMProfile>]
      [<CommonParameters>]
Select-AzureSubscription
      [-Account <String>]
      [-NoDefault]
      [-PassThru]
      [-Profile <AzureSMProfile>]
      [<CommonParameters>]

Description

The Select-AzureSubscription cmdlet sets and clears the current and default Azure subscriptions.

The "current subscription" is the subscription that is used by default in the current Windows PowerShell session. The "default subscription" is used by default in all Windows PowerShell sessions. The "current subscription" label lets you specify a different subscription to be used by default for the current session without changing the "default subscription" for all other sessions.

The "default" subscription designation is saved in your subscription data file. The session-specific "current" designation is not saved.

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: Set the current subscription

C:\PS> Select-AzureSubscription -Current -SubscriptionName ContosoEngineering

This command makes "ContosoEngineering" the current subscription.

Example 2: Set the default subscription

C:\PS> Select-AzureSubscription -Default -SubscriptionName ContosoFinance -SubscriptionDataFile "C:\subs\MySubscriptions.xml"

This command changes the default subscription to "ContosoFinance." It saves the setting in the Subscriptions.xml subscription data file, instead of the default subscription data file.

Parameters

-Account

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-Current

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Default

Type:SwitchParameter
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-NoCurrent

Type:SwitchParameter
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-NoDefault

Type:SwitchParameter
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-PassThru

Returns $True if the command succeeds and $False if it fails. By default, this cmdlet does not return any output.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters: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.

Type:AzureSMProfile
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-SubscriptionId

Type:String
Aliases:Id
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-SubscriptionName

Type:String
Aliases:Name
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

Inputs

None

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

Outputs

None or System.Boolean

If you use the PassThru parameter, this cmdlet returns a Boolean value. By default, it does not generate any output.