Removing a virtual machine
In the life cycle of a virtual machine, there comes a time when you may want to remove it. This may be because the application running on the virtual machine is not in use anymore or because the operating system running on the virtual machine is obsolete and you have moved the application to a new server. To remove a virtual machine, you can use the
Remove-VM
cmdlet, which has the following syntax:
Remove-VM [-DeletePermanently] [-RunAsync] [-VM] <VirtualMachine[]> [-Server <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
If you use the –DeletePermanently
parameter, the virtual machine will be removed from your vSphere inventory and from the datastores. If you omit the –DeletePermanently
parameter, the virtual machine will only be removed from the vSphere inventory. Because the virtual machine's files remain on the datastores, you can register the virtual machine again.
In the following example, we will use the Remove-VM
cmdlet to remove...