< Back

Set-AzureSubscription

Wed Jan 30, 2019 5:54 pm

NAME Set-AzureSubscription



SYNOPSIS

Creates or changes an Azure subscription





SYNTAX

Set-AzureSubscription [-SubscriptionName] <String> [-Certificate <X509Certificate2>] [-CurrentStorageAccountName <String>] [-PassThru]

[-ResourceManagerEndpoint <String>] [-ServiceEndpoint <String>] [-SubscriptionDataFile <String>] [-SubscriptionId <String>] [<CommonParameters>]



Set-AzureSubscription [-SubscriptionName] <String> [-PassThru] [-SubscriptionDataFile <String>] [<CommonParameters>]





DESCRIPTION

The Set-AzureSubscription cmdlet establishes and changes the properties of an Azure subscription. You can use this cmdlet to create a new subscription

or change the properties of an existing subscription.



To create a new subscription, select a unique name for the value of the SubscriptionName parameter. To change an existing subscription, use the

SubscriptionName parameter to identify the subscription.



This cmdlet changes the data in the subscription data file that you create when you use the Add-AzureAccount or Import-AzurePublishSettingsFile cmdlet

to add an Azure account to Windows PowerShell.



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

-Certificate <X509Certificate2>

Specifies a management certificate for the subscription. Management certificates are X.509 certificates that are saved as .cer files and uploaded to

the Azure Management Portal. The certificate, including its private key, must be installed on the local computer, either in the current user's

personal certificate store, or the local machine???s personal certificate store.



Required? false

Position? named

Default value

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-CurrentStorageAccountName <String>

Designates the specified storage account as the "current" storage account for the subscription. Enter the storage account name. The parameter value

is case-sensitive. Wildcard characters are not permitted.



This parameter does not create a storage account; it just associates the storage account with the subscription. To create a storage account, use the

New-AzureStorageAccount cmdlet.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-PassThru [<SwitchParameter>]

Returns True ($true) if the operation succeeds and False ($false) if it fails. By default, this cmdlet does not return any output.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-ResourceManagerEndpoint <String>

Sets or changes the endpoint for Azure Resource Manager data to the specified value.



For more information about Azure Resource Manager, see Azure Resource Manager Cmdlets (http://go.microsoft.com/fwlink/?LinkID=394765) and Using

Windows PowerShell with Resource Manager (http://go.microsoft.com/fwlink/?LinkID=394767).



Required? false

Position? named

Default value

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-ServiceEndpoint <String>

Sets or changes the custom service endpoint for the management service to the specified value.



The service endpoint is the Azure management API endpoint in the Azure environment. You can create custom service endpoints and set a different

service endpoint for each subscription.



Required? false

Position? named

Default value

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-SubscriptionDataFile <String>

Specifies the path and filename of an alternate subscription data file. This parameter is optional. By default, Set-AzureSubscription gets and

changes data in the default subscription data file in your roaming user profile. Use this parameter if you used the SubscriptionDataFile parameter

in Add-AzureAccount or Import-AzurePublishSettingsFile to specify an alternate (non-default) location for this file.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-SubscriptionId <String>

Specifies the ID of the subscription. To get the subscription ID of an existing Azure subscription, use the Get-AzureSubscription cmdlet.



Required? false

Position? named

Default value

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-SubscriptionName <String>

Specifies the subscription name. If an Azure subscription with this name does not exist, this parameter creates a new subscription with the

specified name. If the subscription exists, this parameter identifies the subscription and uses the other property values to change it.



To get the names of existing Azure subscriptions, use the Get-AzureSubscription cmdlet.



Required? true

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

None or System.Boolean



When you use the PassThru parameter, this cmdlet returns a Boolean value. By default, this cmdlet does not return any output.





NOTES





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



Example 1: Create a new subscription



PS C:\\>$thumbprint = <Certificate Thumbprint>

PS C:\\>$myCert = Get-Item cert:\\\\CurrentUser\\My\\$thumbprint

PS C:\\>Set-AzureSubscription -SubscriptionName ContosotTest -Certificate $myCert -SubscriptionID 12345



These commands create the ContosoTest subscription in the default subscription data file. The commands add a management certificate and subscription ID

for the new subscription.



When you run the Set-AzureSubscription command, the cmdlet looks for a subscription with the name "ContosoTest". If it doesn't find one, it creates a

new subscription with the specified values.

Example 2: Change an existing subscription



C:\\PS> $thumbprint = <Thumbprint-2>

C:\\PS> $differentCert = Get-Item cert:\\\\CurrentUser\\My\\$thumbprint

C:\\PS> Set-AzureSubscription ???SubscriptionName ContosoEngineering -Certificate $differentCert



These commands are very similar to the commands in Example 1. However, because the SubscriptionName parameter now identifies an existing subscription,

Set-AzureSubscription uses the remaining parameters to change the values of the existing subscription rather than creating a new subscription

Example 2: Change the service endpoint



C:\\PS> Set-AzureSubscription ???SubscriptionName ContosoEngineering -ServiceEndpoint "https://management.core.contoso.com"



This command adds or changes a custom service endpoint for the ContosoEngineering subscription.

Example 3: Clear property values



C:\\PS> Set-AzureSubscription ???SubscriptionName ContosoEngineering ???Certificate $null -ResourceManagerEndpoint $null



This command sets the values of the Certificate and ResourceManagerEndpoint properties to null ($null). This clears the values of those properties

without changing other settings.

Example 4: Use an alternate subscription data file



C:\\PS> Set-AzureSubscription -SubscriptionName ContosoFinance -SubscriptionDataFile = C:\\Azure\\SubscriptionData.xml - CurrentStorageAccount

ContosoStorage01



This command changes the current storage account of the ContosoFinance subscription to ContosoStorage01. The command uses the SubscriptionDataFile

parameter to change the data in the C:\\Azure\\SubscriptionData.xml subscription data file. By default, Set-AzureSubscription uses the default

subscription data file in your roaming user profile.



RELATED LINKS

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

Add-AzureAccount

Get-AzureSubscription

Import-AzurePublishSettingsFile

Remove-AzureSubscription

Select-AzureSubscription