VirtualMetric Hyper-V Monitoring, Hyper-V Reporting


Microsoft PowerShell MVP

Cozumpark Bilisim Portali
Hyper-V VM Migration Script v1.4 – Quick Migration from v2 to v3
Posted in Virtual Machine Manager, Windows Powershell | 10 Comments | 11,061 views | 04/04/2013 20:25

Hi guys and ladies! :)

Update: v1.4 is here! Thanks for your feedbacks.

Hyper-V VM Migration Script is ready! Now it’s possible to migrate your VMs from Hyper-V v2 to Hyper-V v3 with quick migration capabilities.

It supports following scenarios:

1. Standalone Hyper-V v2 Host
2. Hyper-V v2 Host in trusted domain
3. Hyper-V v2 Host in untrusted domain

Update v1.4:
1. Fixed network configuration issue on different subnets
2. Improved debugging

Update v1.3:
1. Added support for servers on different subnets

Update v1.2:
1. Linux VM migration support
2. Fixed a bug while getting vhd name
3. Advanced debugging switch (use -DebugMode)

So why it supports untrusted domains? Because you may not want to install Windows Server 2012 Cluster into your existing Windows Server 2008 R2 environment. If you have totally different environment for Hyper-V v3, then this script is your best friend.


1. It supports BITS! It’s ready to move large VHD files.
2. It supports “Rollback“. If there will be any problem, this script will undo any changes!!! :)
3. Licensed in GPLv2. You can use this script in your organization without any licensing issues. Totally free!

How to Install?
1. First download Hyper-V VM Migration Script:
Download Script

2. You can use exe or msi file to installation. I’ve just used migration.exe file to installation.

3. Change Powershell path if you have different drive path.

4. Click Install to begin installation.

5. That’s it! You can start using migration script.

6. Go to Powershell and type following to change execution policy as “AllSigned”.

Set-ExecutionPolicy AllSigned

7. Allow my code publishing certificate. This will prevent you to run untrusted scripts.


8. Installation is done! Now we can start migration of virtual machines.

How to use?

Example 1: If want to migrate VM01 from HV001 ( to your local Hyper-V v3 host, use following:

New-Migration -VMName "VM01" -VMHost "HV001" -VMPath "C:\ClusterStorage\Volume1"

BTW, -VMPath switch is the destination path. Not your current VM path. This script finds VM path automatically.

Example 2: If HV001 ( is a standalone machine, use following:

New-Migration -VMName "VM01" -VMHost "" -Username "Administrator" -Password "123456" -VMPath "C:\ClusterStorage\Volume1"

Example 3: If HV001 ( is a member of a untrusted domain, use following:

New-Migration -VMName "VM01" -VMHost "" -Username "Domain\Administrator" -Password "123456" -VMPath "C:\ClusterStorage\Volume1"

Example 4: Having trouble with migration? Use debugging switch (-DebugMode) to see what really makes that problem:

New-Migration -VMName "VM01" -VMHost "" -VMPath "C:\ClusterStorage\Volume1" -DebugMode


1. You should install this script on to your Hyper-V v3 host.

2. This script doesn’t allow you to migrate VMs if they have snapshots. You should remove them first.

3. Requires Powershell v3. (It comes by default on Windows Server 2012)

4. Hyper-V v2 host and Hyper-V v3 host should have same network switch names. If they are different, this script connects first external network to your virtual machine.

Thanks for using Hyper-V VM Migration script!


Comments (10)

Server 2012 is now RTM!! – Page 2

August 4th, 2012

[…] This could be useful… Hyper-V VM Migration Script – Quick Migration from v2 to v3 Reply With […]


October 10th, 2012

Super! Tool!!!
Thank you, Yusuf Ozturk !!!

Yusuf Ozturk » How to migrate Hyper-V v3 VM back to Hyper-V v2 environment

October 10th, 2012

[…] Of course if you need to migrate a VM from Hyper-V v2 to Hyper-V v3, you can use this script for quick migration:… […]


January 14th, 2013

Hi Yusuf, thanks for helping others, your script is very usefull to me, but recently i had error running it, the error is:

Test-Path : Cannot bind argument to parameter ‘Path’ because it is an empty string.
At C:\windows\system32\windowspowershell\v1.0\Modules\Migration\Migration.ps1:1346 char:37
+ $TestVMFullPath = Test-Path -Path “$VMFullPath”
+ ~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Test-Path], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.PowerShell.Commands.Test

it was running fine until some days ago, my script is:

New-Migration -VMName “vgissrv” -VMHost “HV10SRV” -VMPath “C:\ClusterStorage\Volume2”

thanks again for your help.

from Bolivia


January 14th, 2013

Hi Armando,

Could you start Powershell console with admin privileges? Also maybe you logged in with local administrator account? I think PS Session can not access to C:\ClusterStorage\Volume2. After opening PS Console, can you do “cd C:\ClusterStorage\Volume2”?



January 14th, 2013

Hi Yusuf,

I am logged as domain user (domain admin) and also this user is in the administrators group, ps is launched with elevated priv. and i an access any path:

PS C:\Windows\system32> cd..
PS C:\Windows> cd..
PS C:\> cd .\ClusterStorage
PS C:\ClusterStorage> cd .\Volume2
PS C:\ClusterStorage\Volume2> dir
Directory: C:\ClusterStorage\Volume2

Mode LastWriteTime Length Name
—- ————- —— —-

It was working fine until now, this error come without any apparent reason.

thanks for your help



January 16th, 2013

Hi Armando,

Could you start it with -DebugMode switch? It must give you detailed output. At least we may know which step is failed.

Example: New-Migration -VMName “vgissrv” -VMHost “HV10SRV” -VMPath “C:\ClusterStorage\Volume2″ -DebugMode



March 14th, 2013

Hi Yusuf,
How can i use this script if a want to automate like a batchmigration of 25 VMs? Is it only possible to migrate 1 VM at same time?

thanks for your help


April 4th, 2013

Hi Tom,

You can start as many as at once like:

New-Migration -VMName “vgissrv1”
New-Migration -VMName “vgissrv2”
New-Migration -VMName “vgissrv3”

Just copy/past them into PS screen, so when first one is done, it will go to second one.
This script doesn’t support getting list of all virtual machines, due to prevent mistakes.


NeWay Technologies – Weekly Newsletter #37 – April 4, 2013NeWay | NeWay

April 6th, 2013

[…] Hyper-V VM Migration Script v1.4 – Quick Migration from v2 to v3 – […]

Leave a Reply