Written by 11:01 pm Microsoft, PowerShell, Virtualization, Windows, Windows Server • 5 Comments

Hyper-V 3: Import and Export VMs with PowerShell

Hyper-V-Powershell02

Aidan Finn (Virtual Machine MVP) just made a blog post about Hyper-V & PowerShell in Windows Server 8 and how you can enable Hyper-V via PowerShell in Windows Server 8. So this gave me the idea about doing a little more with PowerShell and Hyper-V 3.

I already did a blog post about how you can attach multiple VHDs to a SCSI Controller with PowerShell in Windows Server 8. In this post I will show how easy you can export and import a lot of Virtual Machines.

First you can run a Get-VM Test*, to check which VMs you will export.

 
Get-VM Test*

Now you can export the Virtual Machines

 
Get-VM Test* | Export-VM -Path "C:\VMs"

Now I removed the Virtual Machines in Hyper-V with Powershell (You could also add the -confirm parameter so you don’t have to press “y” for each VM.

 
Get-VM Test* | Remove-VM

And now you can import the Virtual Machines again

 
Get-Childitem "C:\VMs" -Recurse *.xml | Import-VM

Hyper-V-Powershell01

I will post more about PowerShell in Windows 8 and Windows Server 8 (Hyper-V 3) in the next upcommig weeks. If you want know more about what new Hyper-V features and improvments are coming in Windows Server 8, you can read the following blog post: “Hyper-V: Version 3 kills them all

 

Tags: , , , , , , , , , , , , , Last modified: January 7, 2019
Close Search Window
Close