WavebreakmediaMicro - Fotolia

Execute Import-VM and Export-VM PowerShell commands in Hyper-V

Although you can use Hyper-V Manager or SCVMM to import and export VMs, it's just as easy to use a couple PowerShell commands to perform those actions.

You can import and export VMs using Hyper-V Manager or System Center Virtual Machine Manager, but it's just as easy to use PowerShell commands. Microsoft offers the necessary commands to perform both import and export operations for VMs running on Hyper-V.

Export-VM cmdlet

The Export-VM PowerShell cmdlet is available on any computer on which the Hyper-V role is installed, but you can also install Hyper-V PowerShell modules on a management server and perform necessary Hyper-V operations. To export a single VM, execute the following command:

“Export-VM <VMName> -Path “<PathToExportVMFiles>”

Export-VM takes the necessary actions before exporting VM files, such as creating a folder on the path specified in the -Path variable, which creates three subfolders: Snapshots, Virtual Hard Disks and Virtual Machines. These subfolders contain VM files, such as the extensible markup language (XML) file, which contains VM configuration, VM snapshot and VHDX files. If you want to export all VMs running on the local Hyper-V host, run the Get-VM | Export-VM –Path <PathToExportVMFiles> command. If you want to export specific VMs, all you have to do is create a text file that contains VM names and then execute the PowerShell script below.


ForEach ($VMName in Get-Content "$VMFile")


Export-VM -Name $VMName -Path "E:\VMs\"


This will export only the VMs specified in the C:\Temp\VMs.txt file. All VMs will be exported under the E:\VMs folder.

It's important to note that Export-VM doesn't support a -ComputerName parameter, which you can use to export a VM on a remote Hyper-V host.

Import-VM cmdlet

The Import-VM PowerShell cmdlet can help you import a VM. To import a VM, execute the command below:


When it comes to importing a VM, the import process takes any necessary actions. For example, if the VM is already registered with Hyper-V, it deletes the existing VM with the same VM globally unique identifier and then registers the VM again. If you are importing the VM on a different Hyper-V host, the import process just proceeds with the registration of the VM because the VM doesn't already exist. Note that you shouldn't import multiple VMs using a PowerShell script as the import process also checks the VM's compatibility on the target Hyper-V host.

Next Steps

Tap into the PowerShell pipeline

Navigate Windows PowerShell with this guide

Use PowerShell to configure Hyper-V replication

Dig Deeper on Microsoft Hyper-V management