Reputation: 510
I have a bunch of Hyper-V virtual disks I would like to import. My OS is Windows 8.
There are official Microsoft labs images and I can import them from the GUI by following this procedures:
This works perfectly, but since I have a lot of labs, I want to automate this is via a PowerShell script. The Import-VM command accepts a Path parameter which is the path to the VM's XML file. However, the XML files do not exist in my machines until the import is completed via the GUI.
I need some guidance on how I can automate the manual procedure above via PowerShell, i.e. leverage Import-VM to import from a folder path only.
This would save me a ton of time when re-creating my labs across my student's machines.
Any help is appreciated.
Upvotes: 1
Views: 2919
Reputation: 510
Figured it out. The trick was to call Import-VM and specify a path to the .exp which comes with the labs.
Import-VM -Path $expfile
This post really helped: http://vniklas.djungeln.se/2012/04/04/importing-vm%C2%B4s-with-powershell-into-win8-hyper-v-3-0/
Upvotes: 1
Reputation: 10107
Use New-VM
cmdlet instead ie. New-VM –Name "VM1" –MemoryStartupBytes 1GB –VHDPath C:\vhds\yourImage.vhdx -Path C:\VMS
Run get-help New-VM -Examples
or visit http://technet.microsoft.com/en-us/library/hh848537.aspx for more info.
Upvotes: 0