Remove-AzVM

Cmdlet: Remove-AzVM

Module: Az.Compute

Description

The Remove-AzVM cmdlet deletes a virtual machine (VM) from Azure. You can use the -Force parameter to delete the VM without prompting for confirmation.

Syntax

Remove-AzVM
   [-Name] <String>
   [-ResourceGroupName] <String>
   [-Force]
   [-AsJob]
   [-NoWait]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Parameters

Parameter Description Type
-Name Specifies the name of the virtual machine to remove. String
-ResourceGroupName Specifies the name of the resource group that contains the virtual machine. String
-Force Forces the command to run without asking for user confirmation. Switch
-AsJob Run cmdlet in the background using Azure PowerShell Job. Switch
-NoWait Send the request and return immediately, without waiting for the operation to complete. Switch
-WhatIf Shows what would happen if the cmdlet runs. The cmdlet is not run. Switch
-Confirm Prompts you for confirmation before running the cmdlet. Switch

Examples

Example 1: Delete a VM

Remove-AzVM -ResourceGroupName "MyResourceGroup" -Name "MyVM"

This command deletes the VM named "MyVM" in the resource group "MyResourceGroup". The cmdlet will prompt for confirmation before deleting.

Example 2: Delete a VM without confirmation

Remove-AzVM -ResourceGroupName "MyResourceGroup" -Name "MyVM" -Force

This command deletes the VM named "MyVM" in the resource group "MyResourceGroup" without prompting for confirmation.

See Also