VMware Cloud Community
Mr_G_Grant
Enthusiast
Enthusiast
Jump to solution

Move VM disk from one datastore to another

Hi Guys,

In my environment we have virtual machines split over two data stores. I'm trying to migrate all the disks from one data store to another using the following code.

$HD = get-harddisk -Datastore "f2as01_nfs_hoss01"

foreach ($i in $HD) {

Move-HardDisk -HardDisk $i -Datastore "f1aa01_nfs_hoss01" -Confirm:$false

}

However i get the following error:

Move-HardDisk : 26/03/2014 12:53:40    Move-HardDisk        The specified parameter 'Datastore' expects a single value, but your name criteria 'f1aa01_nfs_hoss01' corresponds to multiple values.   
At C:\Users\grantg\AppData\Local\Temp\5eed2c4f-a0e2-4a09-8855-1efcf58fbc90.ps1:7 char:14
+ Move-HardDisk <<<<  -HardDisk $i -Datastore "f1aa01_nfs_hoss01" -Confirm:$false }
    + CategoryInfo          : InvalidResult: (System.Collecti...dObjectInterop]:List`1) [Move-HardDisk], VimException
    + FullyQualifiedErrorId : Core_ObnSelector_SelectObjectByNameCore_MoreResultsThanExpected,VMware.VimAutomation.ViCore.Cmdlets.Commands.VirtualDevice.MoveHardDisk

I know PS does not like spaces but could there be an issues with underscores too?

Regards

Mr G

Reply
0 Kudos
1 Solution

Accepted Solutions
Borja_Mari
Virtuoso
Virtuoso
Jump to solution

Hello,

as commented, maybe there are more than 2 datastores with the name "f1aa01_nfs_hoss01" (in different hosts).

When using powercli, it isn't a good praxis to have more than one datastore with the same name.

You should change the name of the datastore(s), in order to have just one datastore with the same name.

Until you do this, the powercli script will fail!

Best regards,

Pablo

------------------------------------------------------------------------------------------------- PLEASE CONSIDER AWARDING any HELPFUL or CORRECT reply. Thanks!! Por favor CONSIDERA PREMIAR cualquier respuesta ÚTIL o CORRECTA . ¡¡Muchas gracias!! VCP3, VCP4, VCP5-DCV (VCP550), vExpert 2010, 2014 BLOG: http://communities.vmware.com/blogs/VirtuallyAnITNoob

View solution in original post

Reply
0 Kudos
3 Replies
knikolov
VMware Employee
VMware Employee
Jump to solution

For some reason it finds more than one datastore with that name. Try Get-Datastore "f1aa01_nfs_hoss01" and check what the results are.

Reply
0 Kudos
Borja_Mari
Virtuoso
Virtuoso
Jump to solution

Hello,

as commented, maybe there are more than 2 datastores with the name "f1aa01_nfs_hoss01" (in different hosts).

When using powercli, it isn't a good praxis to have more than one datastore with the same name.

You should change the name of the datastore(s), in order to have just one datastore with the same name.

Until you do this, the powercli script will fail!

Best regards,

Pablo

------------------------------------------------------------------------------------------------- PLEASE CONSIDER AWARDING any HELPFUL or CORRECT reply. Thanks!! Por favor CONSIDERA PREMIAR cualquier respuesta ÚTIL o CORRECTA . ¡¡Muchas gracias!! VCP3, VCP4, VCP5-DCV (VCP550), vExpert 2010, 2014 BLOG: http://communities.vmware.com/blogs/VirtuallyAnITNoob
Reply
0 Kudos
DZ1
Hot Shot
Hot Shot
Jump to solution



You may also want to specify the Datacenter and/or cluster name explicitly first.  Get-Datacenter "Name" | get-datastore "Name"

Reply
0 Kudos