VMware Cloud Community
bowulf
Enthusiast
Enthusiast
Jump to solution

Storage Vmotion multiple datastores from CSV

I have 6 VMs with 13 disks each on 72 different datastores (2TB limit was really limiting).  Extents led to terrible performance, so the best course of action was individual disks on individual datastores (1 vmdk to 1 datastore ratio).  We are now migrating all these 72 vmdk's to 72 new datastores on new storage.  In the past, we have done these Storage VMotions via PowerCli either by datastore or by VM to a specified datastore in a comma-delimited file. 

I was trying to figure out what the command line would be as I could insert the appropriate Hard Disks and datastores in the "for each" command.  The set-harddisk command was not working.  Can you see where I went wrong?

[vSphere PowerCLI] C:\powershell> get-datastore HO-CX3-FC-Phopdnode03-1m | Get-HardDisk | % {Set-HardDisk -HardDisk $_ -Datastore "ho_na3_phopdnode03_12" }
Confirm
Are you sure you want to perform this action?
Performing operation "Setting Datastore: ho_na3_phopdnode03_12." on Target"phopdnode03.vmdk".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help
(default is "Y"):
Set-HardDisk : 8/9/2011 3:17:13 PM    Set-HardDisk        Error caused by file
/vmfs/volumes/4e4178ca-0c93f7f8-7141-002655503f5d/phopdnode03/phopdnode03.vmdk
At line:1 char:72
+ get-datastore HO-CX3-FC-Phopdnode03-1m | Get-HardDisk | % {Set-HardDisk <<<<
-HardDisk $_ -Datastore "ho_na3_phopdnode03_12" }
    + CategoryInfo          : NotSpecified: (:) [Set-HardDisk], FileFault
    + FullyQualifiedErrorId : Client20_VirtualDeviceServiceImpl_MoveVirtualHar
   dDiskFile_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.VirtualDevi
  ce.SetHardDisk
Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

The Get-Harddisk cmdlet with the Datastore parameter returns also .vmdk files that are not connected to a VM.

A svMotion has to update the VM's .vmx file as well.

Try it perhaps like this

Get-VM -Datastore "HO-CX3-FC-Phopdnode03-1m" | Get-Harddisk | `

where {$_.Filename -match "HO-CX3-FC-Phopdnode03-1m"} | `

Set-Harddisk -Datastore "ho_na3_phopdnode03_12"


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

View solution in original post

Reply
0 Kudos
6 Replies
LucD
Leadership
Leadership
Jump to solution

The Get-Harddisk cmdlet with the Datastore parameter returns also .vmdk files that are not connected to a VM.

A svMotion has to update the VM's .vmx file as well.

Try it perhaps like this

Get-VM -Datastore "HO-CX3-FC-Phopdnode03-1m" | Get-Harddisk | `

where {$_.Filename -match "HO-CX3-FC-Phopdnode03-1m"} | `

Set-Harddisk -Datastore "ho_na3_phopdnode03_12"


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

Reply
0 Kudos
bowulf
Enthusiast
Enthusiast
Jump to solution

I received a slightly different error message this time.  (Name changed to reflect the new datastore) 

Get-VM -Datastore "HO-CX3-FC-Phopdnode05-1m" | Get-Harddisk | where {$_.Filename -match "HO-CX3-FC-Phopdnode05-1m"} | Set-Harddisk -Datastore "ho_na3_phopdnode05_12"

Confirm

Are you sure you want to perform this action?

Performing operation "Setting Datastore: ho_na3_phopdnode05_12." on Target

"Hard disk 13".

[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help

(default is "Y"):y

Set-HardDisk : 8/10/2011 9:08:46 AM    Set-HardDisk        The operation for th

e entity VirtualMachine-1328 failed with the following message: "The operation

is not supported on the object."

At line:1 char:131

+ Get-VM -Datastore "HO-CX3-FC-Phopdnode05-1m" | Get-Harddisk | where {$_.Filen

ame -match "HO-CX3-FC-Phopdnode05-1m"} | Set-Harddisk <<<<  -Datastore "ho_na3_

phopdnode05_12"

    + CategoryInfo          : NotSpecified: (:) [Set-HardDisk], NotSupported

    + FullyQualifiedErrorId : Client20_TaskServiceImpl_CheckServerSideTaskUpda

   tes_OperationFailed,VMware.VimAutomation.ViCore.Cmdlets.Commands.VirtualDe

  vice.SetHardDisk

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Are you connected to the vCenter or to an ESX(i) server ?


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

Reply
0 Kudos
bowulf
Enthusiast
Enthusiast
Jump to solution

I am connecting to be an ESX 4.1 Build 320092 host, and I am performing this function on the host that owns the virtual machine.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

That's the explanation.

In the Set-Harddisk it says that the Datastore parameter is only supported when you are connected to a vCenter.

The alternative could be to use the SDK method called RelocateVM_Task


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

bowulf
Enthusiast
Enthusiast
Jump to solution

Thanks that solved my problem.  I thought I read somewhere set-harddisk needed to be run on the host itself, but I must have misunderstood.  Running it from vCenter makes my life in scripting the move much easier.  Thanks again!

Reply
0 Kudos