Q. How can I bulk import every exported virtual machine (VM) in a folder?

A. Using the CodePlex Hyper-V module referenced in FAQ "Q. Is there a PowerShell set of cmdlets for Hyper-V outside of using VMM?" you can use the Import-VM cmdlet. Combine this with logic to list every folder in a path to create a command to import every VM in a folder (assuming each VM is in its own child folder). Notice that you use the -Wait switch for the Import-VM to import only one VM at a time.

Get-ChildItem e:\virtuals | Where-Object { $_.Attributes -band [System.IO.FileAttributes]::Directory } | ForEach-Object {Import-VM -path $_.FullName -ReuseIDs -Wait}

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish