Remove-AzureSubscription
[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]
Remove-AzureSubscription
Deletes an Azure subscription from Windows PowerShell.
Syntax
Parameter Set: Default
Remove-AzureSubscription [-SubscriptionName] <String> [[-Force]] [[-PassThru]] [-SubscriptionDataFile <String> ] [-Confirm] [-WhatIf] [ <CommonParameters>]
Detailed Description
The Remove-AzureSubscription cmdlet deletes an Azure subscription from your subscription data file so Windows PowerShell can't find it. This cmdlet does not delete the subscription from Microsoft Azure, or change the actual subscription in any way.
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
-Force
Suppresses the confirmation prompt. By default, Remove-AzureSubscription prompts you before deleting the subscription.
Aliases |
none |
Required? |
false |
Position? |
3 |
Default Value |
none |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-PassThru
Returns True ($true) if the command succeeds and False ($false) if it fails. By default, this cmdlet does not return any output.
Aliases |
none |
Required? |
false |
Position? |
4 |
Default Value |
none |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-SubscriptionDataFile<String>
Deletes the 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>
Specifies the subscription name. This parameter is required. The parameter value is case-sensitive. Wildcard characters are not permitted.
Aliases |
none |
Required? |
true |
Position? |
1 |
Default Value |
none |
Accept Pipeline Input? |
True (ByPropertyName) |
Accept Wildcard Characters? |
false |
-Confirm
Prompts you for confirmation before running the cmdlet.
Required? |
false |
Position? |
named |
Default Value |
false |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Required? |
false |
Position? |
named |
Default Value |
false |
Accept Pipeline Input? |
false |
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.
None or System.Boolean
If you use the PassThru parameter, this cmdlet returns a Boolean value. Otherwise, it does not return any output.
Examples
Example 1: Delete a subscription
This command deletes the "Test" subscription from the default subscription data file.
C:\PS> Remove-AzureSubscription -SubscriptionName Test
Confirm
Are you sure you want to perform this action?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):
Example 2: Delete from an alternate subscription data file
This command deletes the Test subscription from the MySubscriptions.xml subscription data file. The command uses the Force parameter to suppress the confirmation prompt.
C:\PS> Remove-AzureSubscription -SubscriptionName Test -SubscriptionDataFile C:\Subs\MySubscriptions.xml -Force
Example 3: Delete a subscription in a script
This command uses the Remove-AzureSubscription command in an If statement. It uses the PassThru parameter, which returns a Boolean value, to determine whether the script block in the If statement is executed.
C:\PS> ...if (Remove-AzureSubscription -SubscriptionName Test -PassThru) {...}