VMware Cloud Community
DavidRDX
Contributor
Contributor

How to move VM hardDisk to different folder on same datastore via powercli?

I'm looking into powercli solution to move vmdk file (second/third/... harddisk of existing vm) to new vm folder.

I was looking at the move-harddisk command but I only see datastore as destination but no option to specify folder?

Does anyone got solution?

thanks.

0 Kudos
7 Replies
LucD
Leadership
Leadership

I'm afraid you will have to use the MoveVirtualDisk method.
See for example Solved: Re: Move, Remove, or Copy an orphaned VMDK all res... - VMware Technology Network VMTN


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

hadjer1
Enthusiast
Enthusiast

Hello,

May be you can detach the disk, move it to the desired folder and then attach it back to the VM.

0 Kudos
LucD
Leadership
Leadership

And isn't that "...move it to the desired folder ..." in fact the same as the original question in the thread?


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

0 Kudos
hadjer1
Enthusiast
Enthusiast

I mean move it using a utility such as WinSCP. @LucD 

0 Kudos
LucD
Leadership
Leadership

Really, you are going to enable SSH on the ESXi node, store the VMDK on your Windows box and then import it back into the ESXi node?
That is a rather cumbersome method to copy a VMDK between folders.
And I don't see where PowerCLI, as the user asked, comes into play in that scenario.


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

0 Kudos
hadjer1
Enthusiast
Enthusiast

Hello @LucD ,

The datastores are all mounted in ESXI host , so you don't need to copy the vmdk into your computer, it can be done simply from WinSCP directly from folder to folder or by just using cp command if you connect to ESXI host using an SSH client.

As for the user's request, I don't know why he needs to do it by power shell command, so I was proposing a workaround.

0 Kudos
DavidRDX
Contributor
Contributor

I prefer scripted method instead of manual action.  We are migrating multiple virtual guests to new os version and second disk is the shared data disk.

0 Kudos