Hyper-V 3: Import and Export VMs with PowerShell
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.[powershell]
Now you can export the Virtual Machines[powershell]
Get-VM Test* | Export-VM -Path “C:\VMs”[/powershell]
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.[powershell]
Get-VM Test* | Remove-VM[/powershell]
And now you can import the Virtual Machines again[powershell]
Get-Childitem “C:\VMs” -Recurse *.xml | Import-VM[/powershell]
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”