Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Import VM to Hyper-V using script?

Posted on 2011-05-08
2
Medium Priority
?
1,452 Views
Last Modified: 2012-05-11
I have a virtual domain named "labdomain" which I use for software testing. I have various Windows versions which I test software against. After testing I delete the VM's and when needed I import them again and start installing the software and test the functionality.
What I really need is a script to import the VM's. They are located on a separate hdd and I always import the same set of VM's. I always use the options "Move or restore .." and "Duplicate all files ..". This manual import is cumbersome, slow and prone to errors. E.g. forgetting to check the "Duplicate all files.." option.

I found a Powershell script suite made for Hyper-V which I tried, it is way too complicated to me. Never got it to work and since I have no clue how it works I am afraid I might break something.

Anyone here got ideas how to solve this?

I use the Hyper-V in Windows 2008 R2.
0
Comment
Question by:jerra
2 Comments
 
LVL 8

Accepted Solution

by:
Bill earned 2000 total points
ID: 35730647
One primitive scripting option would be to:
1- Stop the VM
2- Copy over the .VHD
3- Start the VM
In other words there's no real reason to delete and re-import the VM if it hasn't fundamentally changed:  NIC IP address, etc.

I did find some other resources however to consider.  The following article looks helpful:
http://social.technet.microsoft.com/Forums/en-US/ITCG/thread/602cdab6-96b6-488d-b40b-ecb1b9a22f72/

----
Import-Module Hyper-V
$VMs = Get-VM
foreach($VM in VMs)
{
  Shutdown-VM -VM $VM.VMElementName
  Export-VM -VM $VM.VMElementName -Path <your export path>
  Start-VM -VM $VM.VMElementName
  Import-VM -Path <your export path> -Server <other hyper-v server>
}
----

0
 

Author Closing Comment

by:jerra
ID: 35735190
Excellent, the copying of the .vhd works for me!
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Few best practices specific to Network Configurations to be considered while deploying a Hyper-V infrastructure. It may not be the full list, but this could be a base line. Dedicated Network: Always consider dedicated network/VLAN for Hyper-V…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question