VMware Cloud Community
gruden
Contributor
Contributor

Move-VM with a Datastore Cluster

Hi All,

I'm attempting to script the mass movement of VMs to new datastores that will be part of a datastore cluster.  When I Google this it seems I should be able to specify a datastore cluster object for the -datastore parameter in the Move-VM commandlet, yet when I do I get an error "Could not find StorageResource" even though I pass a valid object.

Can anyone confirm whether this should work (or not)?  I'm using PowerCLI 5.8 if it makes a difference.

Thanks for your help.

0 Kudos
8 Replies
jpsider
Expert
Expert

can you post your code?  Thanks!

0 Kudos
gruden
Contributor
Contributor

It's really simple:

   $task = Move-VM -VM $mvm -Datastore -$dclobj -RunAsync
0 Kudos
jpsider
Expert
Expert

How are you getting that data store?

$myDatastoreCluster1 = Get-DatastoreCluster -Name 'MyDatastoreCluster1'

Move-VM -VM 'MyVM1' -Datastore $myDatastoreCluster1

0 Kudos
gruden
Contributor
Contributor

Yep, nothing special

    $dclobj = Get-DatastoreCluster -name $dcl

Both passed parameters are valid.  When it comes down to it Move-VM doesn't seem to accept a datastorecluster object as valid.  I was hoping someone could tell me definitively if it should be accepted or not.  Maybe a different version of PowerCLI will accept it? 

I have multiple VMs that are very large and span multiple datastores; I was hoping to use a cluster so that it would handle placing the vmdk's on the back-end, as opposed to me trying to do coding acrobatics to make it work (or doing it manually).

0 Kudos
jpsider
Expert
Expert

Can you post the error?

0 Kudos
LucD
Leadership
Leadership

Which PowerCLI version are you running? (do a Get-PowerCLIVersion)


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
jpsider
Expert
Expert

I am also curious what version of vCenter/ESX.

0 Kudos
Freep
Contributor
Contributor

If you copied and pasted the actual code you used, you have a '-' in front of your datastore object name -Datastore -$dclobj . That would be your problem if it were that simple.

0 Kudos