Remove-VM
Deletes a virtual machine.
Remove-VM
[-ComputerName <String[]>]
[-Name] <String[]>
[-Force]
[-AsJob]
[-Passthru]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Remove-VM
[-Force]
[-AsJob]
[-Passthru]
[-VM] <VirtualMachine[]>
[-WhatIf]
[-Confirm]
[<CommonParameters>]
The Remove-VM cmdlet deletes a virtual machine. Running this cmdlet deletes the virtual machine's configuration file, but does not delete any virtual hard drives. If the virtual machine has any snapshots, these are deleted and merged into the virtual hard disk files after the virtual machine is deleted.
PS C:\>Remove-VM "new 1"
Confirm: Are you sure you want to remove virtual machine "new 1"?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): y
Removes virtual machine new 1.
PS C:\>Remove-VM -Name "new 2" -Force
Removes virtual machine new 2, suppressing the confirmation prompt.
PS C:\>Get-VM -Name New* | Remove-VM -Force
Removes with no confirmation prompt all virtual machines having names starting with New.
Specifies that this cmdlet is to be run as a background job.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies one or more Hyper-V hosts from which the virtual machine is to be deleted. NetBIOS names, IP addresses, and fully-qualified domain names are allowable. The default is the local computer - use "localhost" or a dot (".") to specify the local computer explicitly.
Type: | String[] |
Position: | Named |
Default value: | . |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Prompts you for confirmation before running the cmdlet.
Type: | SwitchParameter |
Aliases: | cf |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies that confirmation prompts are to be suppressed during deletion of the virtual machine.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies the name of the virtual machine to be deleted.
Type: | String[] |
Aliases: | VMName |
Position: | 0 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies that an object is to be passed through to the pipeline representing the virtual machine to be deleted.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies the virtual machine to be deleted.
Type: | VirtualMachine[] |
Position: | 0 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: | SwitchParameter |
Aliases: | wi |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
None by default; Microsoft.HyperV.PowerShell.VirtualMachine if -PassThru is specified.