Manipulate VM's on Hyper-V

  • Print
Hereby some simple command lines to export, remove and import again an VM in Hyper-V.
Export the VM:
export-vm -Path Path-to-export -VM "VM VMElementName" -server Hostname
Path to which the export is performed. Notice that if you do this remotely, the path is locally on the Hyper-V host.
VM VMElementName:
A understandable name of the VM, which is set at the creation of the VM.
Hostname of the Hyper-V server. If performed locally, you may use "."
export-vm -Path C:\Temp\Demo1 -VM "DP-Test" -server demoserver
Remove VM
remove-vm -vm VM VMElementName -server Hostname -Force
remove-vm -vm DP-Test -server demoserver -Force
Import VM
import-vm -Paths Path-to-import -server Hostname -wait
import-vm -Paths C:\temp\DP-Demo\ -server -wait
More info here