Remove-AzureResource
Remove-AzureResource
Deletes a resource.
Syntax
Parameter Set: Default
Remove-AzureResource -ApiVersion <String> -Name <String> -ResourceGroupName <String> -ResourceType <String> [-Force] [-ParentResource <String> ] [-PassThru] [-Profile <Microsoft.Azure.Common.Authentication.Models.AzureProfile> ] [-Confirm] [-WhatIf] [ <CommonParameters>]
Detailed Description
The Remove-AzureResource cmdlet deletes a resource from your subscription. It does not delete the resource group of the resource.
By default, Remove-AzureResource prompts you for confirmation. To suppress the prompt, use the Force parameter.
Parameters
-ApiVersion<String>
Specifies the API version that is supported by the resource provider. This parameter is required.
Aliases |
none |
Required? |
true |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
True (ByPropertyName) |
Accept Wildcard Characters? |
false |
-Force
Suppresses the confirmation prompt. By default, Remove-AzureResource prompts for confirmation before deleting a resource.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-Name<String>
Specifies the name of the resource. This parameter is required.
Aliases |
ResourceName |
Required? |
true |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
True (ByPropertyName) |
Accept Wildcard Characters? |
false |
-ParentResource<String>
Specifies the names of the logical parent of a resource. This parameter is optional. Enter the fully qualified name of the parent resource, such as "Microsoft.Sql/servers/ContosoSQLSvr".
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
True (ByPropertyName) |
Accept Wildcard Characters? |
false |
-PassThru
Returns $True when the remove operation succeeds and $False otherwise. By default, this cmdlet does not return any output.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-Profile<Microsoft.Azure.Common.Authentication.Models.AzureProfile>
Specifies the Azure profile from which this cmdlet reads. If you do not specify a profile, this cmdlet reads from the local default profile.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-ResourceGroupName<String>
Specifies the name of resource group of the resource. This parameter is required.
Aliases |
none |
Required? |
true |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
True (ByPropertyName) |
Accept Wildcard Characters? |
false |
-ResourceType<String>
Specifies the resource type. Enter a provider qualified name, such as "Microsoft.Web/sites". This parameter is required. Wildcards are not permitted.
Aliases |
none |
Required? |
true |
Position? |
named |
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: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 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 Boolean
When you use the Passthru parameter, this cmdlet returns a Boolean value that represents the success or failure of the operation. By default, this cmdlet does not generate output.
Notes
- The Remove-AzureResource cmdlet is included in the Azure Resource Manager module beginning in module version 0.8.0.
Examples
Example 1: Remove a resource
This command removes the ContosoWeb web site from the ContosoRG01 resource group.
Remove-AzureResource -Name ContosoWeb -ResourceGroupName ContosoRG01 -ResourceType Microsoft.web/sites -ApiVersion 2015-04-01 ConfirmAre you sure you want to remove resource ' ContosoWeb'[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): y
Example 2: Pipe a resource to Remove-AzureResource
This command uses the Get-AzureResource cmdlet to get the ContosoDB01 database. The command pipes the database to the Remove-AzureResource cmdlet to remove it. The command uses the Passthru parameter, which causes the cmdlet to return a Boolean value that represents the success or failure of the operation. In this case, it returns True.
Get-AzureResource -Name contosodb01 -ResourceGroupName ContosoRG01 -ResourceType "Microsoft.Sql/servers/databases" -ParentResource "Microsoft.Sql/servers/contososvr01" -ApiVersion 2.0 | Remove-AzureResource -Passthru ConfirmAre you sure you want to remove resource 'contosodb01'[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): y