I tried Again using the following code and incorporating an anti-affinity rule in hopes it would work. But failed again:
$vmtomigrate = Get-VM -Name mytestvm
$vmtoavoid = Get-VM -Name 'mdczr1186'
$dsc = Get-DatastoreCluster -Name 'dscluster-vmfarm2.2-silver'
$vmaar= New-Object -TypeName VMware.VimAutomation.ViCore.Types.V1.DatastoreManagement.SdrsVMAntiAffinityRule -ArgumentList $vmtoavoid
Move-VM $vmtomigrate -Datastore $dsc -AdvancedOption $vmaar -DiskStorageFormat 'EagerZeroedThick'
Error msg:
Move-VM : 9/11/2013 1:19:38 PM Move-VM
Required property datastore is missing from data object of type VirtualMachineRelocateSpecDiskLocator
while parsing serialized DataObject of type vim.vm.RelocateSpec.DiskLocator
at line 1, column 891
while parsing property "disk" of static type ArrayOfVirtualMachineRelocateSpecDiskLocator
while parsing serialized DataObject of type vim.vm.RelocateSpec
at line 1, column 877
while parsing property "relocateSpec" of static type VirtualMachineRelocateSpec
while parsing serialized DataObject of type vim.storageDrs.StoragePlacementSpec
at line 1, column 324
while parsing call information for method RecommendDatastores
at line 1, column 218
while parsing SOAP body
at line 1, column 207
while parsing SOAP envelope
at line 1, column 38
while parsing HTTP request for method recommendDatastores
on object of type vim.StorageResourceManager
at line 1, column 0
At line:1 char:8
+ Move-VM <<<< $vmtomigrate -Datastore $dsc -AdvancedOption $vmaar -DiskStorageFormat 'EagerZeroedThick'
+ CategoryInfo : NotSpecified: (:) [Move-VM], InvalidRequest
+ FullyQualifiedErrorId : Client20_VmServiceImpl_RelocateVmThroughSdrs_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.MoveVM
PowerCLI C:\cygwin\home\m437830\scripts_c_drive\powercli> hitory
The term 'hitory' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
At line:1 char:7
+ hitory <<<<
+ CategoryInfo : ObjectNotFound: (hitory:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
I am surprised that there is no way to do the exact same functionality in cli as is done thru the Migration Wizard UI. What is the magic step that I am missing? Help Help