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-Export:
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:
Hostname of the Hyper-V server. If performed locally, you may use "."
Example:
export-vm -Path C:\Temp\Demo1 -VM "DP-Test" -server demoserver
 
Remove VM
remove-vm -vm VM VMElementName -server Hostname -Force
Example:
remove-vm -vm DP-Test -server demoserver -Force
 
Import VM
import-vm -Paths Path-to-import -server Hostname -wait
Example:
import-vm -Paths C:\temp\DP-Demo\ -server 10.3.87.16 -wait
 
More info here