Export (0) Print
Expand All

How to Convert Virtual Machines Using a Script

Updated: January 7, 2010

Applies To: Virtual Machine Manager 2008, Virtual Machine Manager 2008 R2, Virtual Machine Manager 2008 R2 SP1

You can convert VMware Server-based virtual machines to Hyper-V or to Microsoft Virtual Server virtual machines using the V2V conversion feature in System Center Virtual Machine Manager (VMM). This conversion does not affect or delete the original source virtual machine. The conversion is a read-only copy operation that creates a new virtual machine on a VMM host. For more information about how to convert virtual machines and about the requirements for converting VMware Server-based virtual machines, see V2V: Converting Virtual Machines in VMM (http://go.microsoft.com/fwlink/?LinkId=128918). You can use V2V conversion to convert virtual machines that are deployed on VMware ESX Server hosts or that are stored in the library.

ImportantImportant
Before you convert a VMware virtual machine to a Hyper-V virtual machine in VMM, you must uninstall VMware Tools on the guest operating system of the virtual machine.

Explanation of the ConvertESXVMUsingV2VfromHost.ps1 script

The following example converts a virtual machine that is deployed on an ESX Server host to a Hyper-V virtual machine on a VMM host. To copy the entire script, see ConvertESXVMUsingV2VfromHost.ps1.

To start, define the variables. Replace the XX.XXX.XX.XXX placeholder with the computer name of the ESX Server host.


# Filename:      ConvertESXVMUsingV2VfromHost.ps1
# Description:   Converts a virtual machine on a VMware ESX Server host to 
#                a Hyper-V virtual machine on a host managed by VMM.

# Define the variables
$VMHost = Get-VMHost -VMMServer "VMMServer1.Contoso.com" | where {$_.Name -eq "VMMHost1.Contoso.com"}
$VM = Get-VM -Name "ESX Virtual Machine" | where {$_.VMHost.Name -eq "XX.XXX.XX.XXX"}

Use the New-V2V cmdlet to convert the virtual machine. In the following example, provide your virtual machine path for the Path parameter, an actual virtual machine name, the owner, and a new GUID for the JobGroup parameter.

# Convert the virtual machine.
New-V2V -VM $VM -VMHost $VMHost -Path "D:\VirtualMachinePath" -Name "HyperV Virtual Machine" -Description "" -Owner "CONTOSO\phyllis" -RunAsynchronously -JobGroup 1c5728ca-a504-4477-9f55-8a7d3cffd5bf -Trigger -CPUCount 1 -MemoryMB 256 -RunAsSystem -StartAction NeverAutoTurnOnVM -UseHardwareAssistedVirtualization $true -StopAction TurnOffVM

Explanation of the ConvertESXVMUsingV2VfromLibrary.ps1 script

The following example converts a VMware Server-based virtual machine that is stored in the library to a Hyper-V virtual machine on a VMM host. To copy the entire script, see ConvertESXVMUsingV2VfromLibrary.ps1.

To start, define the variables. In the following example, provide your library server name and location.


# Filename:      ConvertESXVMUsingV2VfromLibrary.ps1
# Description:   Converts a VMware virtual machine stored in the library
#                to a Hyper-V virtual machine on a host managed by VMM.

# Connect to the VMM server.
Get-VMMServer -ComputerName "VMMServer1.Contoso.com"

# Define the variables.
$VMHost = Get-VMHost -computername "VMMHost1.Contoso.com"
$VM = Get-VM -VMMServer "VMMServer1.Contoso.com" -Name "ESX Virtual Machine" | where {$_.LibraryServer.Name -eq "VMMServer1.Contoso.com"} | where {$_.Location -eq  "\\VMMServer1.Contoso.com\MSSCVMMLibrary\ESX Virtual Machine"}

Use the New-V2V cmdlet to convert the virtual machine. In the following example, provide your virtual machine path for the Path parameter, an actual virtual machine name, the owner, and a new GUID for the JobGroup parameter.

# Convert the virtual machine.
New-V2V -VM $VM -VMHost $VMHost -Path "D:\VirtualMachinePath" -Name "HyperV Virtual Machine" -Description "" -Owner  "CONTOSO\phyllis" -RunAsynchronously -JobGroup 4d3514f5-1bcf-4d78-8bd1-21e6a7d0a5e4 -Trigger -CPUCount 1 -MemoryMB 256 -RunAsSystem -StartAction  NeverAutoTurnOnVM -UseHardwareAssistedVirtualization $true -StopAction TurnOffVM
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft