Shared Nothing Vmotion

This code will fully migrate a powered on VM to another cluster (On the same vcenter)
This will migrate the VMs storage and the memory state with one command.

### Set your vars
$vmname = “MyVM”
$going2Host = “MyHost.pcli.me”
$datastorename = “Datastore-1”

###
Get-VM $vmname | Move-VM -Destination $going2Host -Datastore (get-datastore “$datastorename”) -confirm:$false -RunAsync:$true

 

####### ####### ####### ####### ####### ####### #######
You can use this code if you want to select the datastore cluster instead of a single LUN.
This may error out if you have SDRS enabled on the VM.
Check this code to disable it before running the migration line below or just disable it via the GUI : http://www.pcli.me/?p=159

$vmname = “MyVM”
$going2Host = “MyHost.pcli.me”
$datastoreclustername = “MyDataStoreCluster”

Get-VM $vmname | Move-VM -Destination $going2Host -Datastore (get-datastorecluster “$datastoreclustername”) -confirm:$false -RunAsync:$true

VMware Links:
http://www.vmware.com/support/developer/PowerCLI/PowerCLI41U1/html/Move-VM.html