VMware Cloud Community
Prower123
Contributor
Contributor

Cloning individual VM hard disks

I've been manually cloning individual hard disks on several VMs for some time now following this KB article, and then removing/adding the newly cloned hard disks on the VM. I was wondering, is there a way with powerCLI to automate this? I was thinking of using get-VMHostDisk in order to get the specific hard disk, however I'm not sure how I would script from there to do the cloning part.

I'll be editing onto this as I attempt to create a script that accomplishes the task of automating that kb article.

Tags (2)
Reply
0 Kudos
3 Replies
ssbkang
Enthusiast
Enthusiast

Reply
0 Kudos
LucD
Leadership
Leadership

I assume the VM is powered off ?

In that case you can use the Copy-Harddisk cmdlet, followed by the New-Harddisk cmdlet with the DiskPath parameter.

Let me know if that helps, or if you need a sample script ?


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

Reply
0 Kudos
Prower123
Contributor
Contributor

What about the vmkfstools? Does copy-harddisk  do the same thing as:

vmkfstools -i /vmfs/volumes/Storage1/examplevm/examplevm.vmdk    /vmfs/volumes/Storage2/examplevm_clone.vmdk

Just wanting to clarify to make sure I understand the cmdlet. As for the script, I'm not that good at scripting so if you could help me get started it would be greatly appreciated.

Reply
0 Kudos