dzi-icomasoft
04.09.2008, 14:00
If you use the PowerScripter plugin (www.powerscripter.net), you could right click on a virtual machine and run the following script. If you donīt have Cluster, you could change the foreach to DataCenter. My issue is, that a get-vmhost -resourcepool $respool is giving no objects -otherwise it would be a lot easier because no knowledge about DataCenter or Cluster would ne needed. It seems to be a VMware VI Toolkit issue.
#--hideoutput
$vm = $_
$vmhost = get-vmhost -VM $vm
$respool = Get-ResourcePool -VM $vm
foreach ($hostrp in (Get-Cluster -VM $vm | get-vmhost)) {
if ($hostrp.name -ne $vmhost.name)
{
Move-VM $vm -Destination $hostrp
Move-VM $vm -Destination $respool
break
}
}
#--hideoutput
$vm = $_
$vmhost = get-vmhost -VM $vm
$respool = Get-ResourcePool -VM $vm
foreach ($hostrp in (Get-Cluster -VM $vm | get-vmhost)) {
if ($hostrp.name -ne $vmhost.name)
{
Move-VM $vm -Destination $hostrp
Move-VM $vm -Destination $respool
break
}
}