If I use vSphere Web Client to storage vMotion a VM, it does a compatibility / validation when I select the datastore and tells me whether the storage vmotion will succeed before I try it. If there are any issues such as the datastore isn't mounted to the ESXi host the VM is on - it will tell me before I attempt the sVmotion and the compatibility check / validation will fail.
What I'd like to do is take a VM I'm about to sVmotion and do a compatibility check before I actually attempt the storage vMotion and see if there are any issues first.
Can this be done in PowerCLI?
Thanks!
Try the following method, I think that is more like the Web Client is showing.
$vmName = 'MyVM'
$tgtDSName = 'MyDS'
$vm = Get-VM -Name $vmName
$ds = Get-Datastore -Name $tgtDSName
$si = Get-View ServiceInstance
$vmProvCheck = Get-View -Id $si.Content.VmProvisioningChecker
$spec = New-Object VMware.Vim.VirtualMachineRelocateSpec
$spec.Datastore = $ds.ExtensionData.MoRef
$result = $vmProvCheck.CheckRelocate($vm.ExtensionData.MoRef,$spec,$null)
$result | %{
$_.Error | Select @{N='Message';E={$_.LocalizedMessage}}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
No cmdlet for that I'm afraid, but the RecommendDatastores method should be able to provide that information.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
OK thanks again. That might actually work. But how would I use it? How would I compare the data store that I want to move my VM to to the list of recommended data stores and see if the data store I want to move it to is in the list?
Try the following method, I think that is more like the Web Client is showing.
$vmName = 'MyVM'
$tgtDSName = 'MyDS'
$vm = Get-VM -Name $vmName
$ds = Get-Datastore -Name $tgtDSName
$si = Get-View ServiceInstance
$vmProvCheck = Get-View -Id $si.Content.VmProvisioningChecker
$spec = New-Object VMware.Vim.VirtualMachineRelocateSpec
$spec.Datastore = $ds.ExtensionData.MoRef
$result = $vmProvCheck.CheckRelocate($vm.ExtensionData.MoRef,$spec,$null)
$result | %{
$_.Error | Select @{N='Message';E={$_.LocalizedMessage}}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Great help - OK thanks again