< Back

Remove-AzureSubscription

Wed Jan 30, 2019 5:41 pm

NAME Remove-AzureSubscription



SYNOPSIS

Deletes an Azure subscription from Windows PowerShell.





SYNTAX

Remove-AzureSubscription [-SubscriptionName] <String> [[-Force]] [[-PassThru]] [-SubscriptionDataFile <String>] [-Confirm] [-WhatIf] [<CommonParameters>]





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 .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

-Force [<SwitchParameter>]

Suppresses the confirmation prompt. By default, Remove-AzureSubscription prompts you before deleting the subscription.



Required? false

Position? 3

Default value

Accept pipeline input? false

Accept wildcard characters? false



-PassThru [<SwitchParameter>]

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



Required? false

Position? 4

Default value

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.



Required? false

Position? named

Default value

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.



Required? true

Position? 1

Default value

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-Confirm [<SwitchParameter>]

Prompts you for confirmation before running the cmdlet.



Required? false

Position? named

Default value false

Accept pipeline input? false

Accept wildcard characters? false



-WhatIf [<SwitchParameter>]

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, 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



If you use the PassThru parameter, this cmdlet returns a Boolean value. Otherwise, it does not return any output.





NOTES





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



Example 1: Delete a subscription



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"):



This command deletes the "Test" subscription from the default subscription data file.

Example 2: Delete from an alternate subscription data file



C:\\PS> Remove-AzureSubscription -SubscriptionName Test -SubscriptionDataFile C:\\Subs\\MySubscriptions.xml -Force



This command deletes the Test subscription from the MySubscriptions.xml subscription data file. The command uses the Force parameter to suppress the

confirmation prompt.

Example 3: Delete a subscription in a script



C:\\PS> ...if (Remove-AzureSubscription -SubscriptionName Test -PassThru) {...}



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.



RELATED LINKS

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

Get-AzureSubscription

Select-AzureSubscription

Set-AzureSubscription