problem defined: trying to cold migrate vms from one datacenter to another datacenter within same vcenter - no matter what code i try to use, i get an error or "half baked" results - i.e. some vms cold migrate, others do not with an error
example001:
PowerCLI C:\> import-csv c:\maint.csv | %{ get-vm -name $_.ServerName -Location (get-datacenter "dtc001") | move-vm -Datastore (get-datastore -name "DATASTORE_008") -RunAsync -Confirm:$false }
maint.csv contents:
ServerName
SERVER001
error in vcenter:
"a specified parameter was not correct. datastore"
example002 - using Lucd's relocatevm method:
foreach($row in (Import-Csv c:\serverlistmigrate.csv -UseCulture)){
$vm = ''
$esx = ''
$spec = ''
$spec.datastore = ''
$spec.host = ''
$spec.resourcepool = ''
CLS
$vmname = $row.vmname
$vmhost = $row.vmhost
$datastore = $row.datastore
$vm = Get-VM -Name $vmname
$spec = New-Object VMware.Vim.VirtualMachineRelocateSpec
$spec.datastore = (Get-Datastore -Name $datastore).ExtensionData.MoRef
$spec.pool = (Get-ResourcePool -Name $resourcepool).ExtensionData.MoRef
$spec.host = (Get-VMHost -Name $vmhost).ExtensionData.MoRef
$vmObj = Get-VM -Name $vmname | Get-View
$vmObj.RelocateVM_Task($spec, "defaultPriority")
}
c:\serverlistmigrate.csv contents:
vmname,vmhost,resourcepool,datastore
"SERVER001,esxhost07,rpl01_High,DATASTORE_008
error in vcenter:
"a specified parameter was not correct. host"
**** USING above method, I will get some to migrate, but some fail with same error as above.
NEEDED: All I want is to cold migrate multiple vms from one datacenter to another datacenter (different datastore) within same vcenter with 100% success - I don't care what method is used - I just need solid, reliable, consistent success.
Many thanks in advance!!!!
NOTES - POWERCLI VERSION, etc.
PowerCLI Version
----------------
VMware vSphere PowerCLI 5.1 Release 1 build 793510
---------------
Snapin Versions
---------------
VMWare AutoDeploy PowerCLI Component 5.1 build 768137
VMWare ImageBuilder PowerCLI Component 5.1 build 768137
VMware License PowerCLI Component 5.1 build 669840
VMware vSphere PowerCLI Component 5.1 build 793489