VMware Cloud Community
The-Kevster
Contributor
Contributor
Jump to solution

Copy-HardDisk while connected to vCenter

Is there a command to copy a virtual machine hard disk while connected to the vCenter server instead of being directly connected to each ESX server?

Thanks,

Kev

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You can use the Copy-DatastoreItem cmdlet but there are some known issues with that cmdlet in the current build.

Or you can use the underlying CopyDatastoreFile_Task method.

Note that you will have to copy all the files (header & flat file) that comprise a vDisk yourself !

____________

Blog: LucD notes

Twitter: lucd22


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

View solution in original post

Reply
0 Kudos
9 Replies
JaviGalvez
Enthusiast
Enthusiast
Jump to solution

You want copy a VM to hard disk of VC?

VCP210, VCP310, VCP410

www.dell.com

VCP210, VCP310, VCP410 www.dell.com
Reply
0 Kudos
The-Kevster
Contributor
Contributor
Jump to solution

Sorry, I should have been more specific. I've been using the below code to copy a VM hard disk from one datastore to another for backup.

CopyVirtualDisk_Task($sourceDisk, $sourceDC.MoRef, $destDisk, $destDC.MoRef, $destSpec, $force)

When I tried to run this against the vCenter server I got the error "The requested operation is not implemented by the server" and the Copy-HardDisk also states that you must be connected directly to the ESX server to run it.

Is there a command to clone a VM hard disk which can be ran from a connectino to the vCenter server?

Thanks again.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

For the CopyVirtualDisk_Task method you have to be indeed conneced to the ESX(i) server.

Same goes for PowerCLI's Copy-HardDisk cmdlet.

____________

Blog: LucD notes

Twitter: lucd22


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

Reply
0 Kudos
The-Kevster
Contributor
Contributor
Jump to solution

Is there a command that can copy the VM hard disk while connected to the vCenter server?

Reply
0 Kudos
JaviGalvez
Enthusiast
Enthusiast
Jump to solution

Mmmmm....The Vm must be OFF? Why not use "Clone" in VC? The ESX servers can access to the other datastore?

VCP210, VCP310, VCP410

www.dell.com

VCP210, VCP310, VCP410 www.dell.com
Reply
0 Kudos
JaviGalvez
Enthusiast
Enthusiast
Jump to solution

Mmmmm....The Vm must be OFF? Why not use "Clone" in VC? The ESX servers can access to the other datastore?

VCP210, VCP310, VCP410

www.dell.com

VCP210, VCP310, VCP410 www.dell.com
Reply
0 Kudos
JaviGalvez
Enthusiast
Enthusiast
Jump to solution

Mmmmm....The Vm must be OFF, Why not use "Clone" in VC? The ESX servers can access to the other datastore?

VCP210, VCP310, VCP410

www.dell.com

VCP210, VCP310, VCP410 www.dell.com
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

You can use the Copy-DatastoreItem cmdlet but there are some known issues with that cmdlet in the current build.

Or you can use the underlying CopyDatastoreFile_Task method.

Note that you will have to copy all the files (header & flat file) that comprise a vDisk yourself !

____________

Blog: LucD notes

Twitter: lucd22


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

Reply
0 Kudos
ykalchev
VMware Employee
VMware Employee
Jump to solution

Summarizing the posts above:

vCenter server API does not support Virtual Disk Manager operations. This means that Copy-HardDisk cmdlet does not work against vCenter Server connection, only against direct ESX connection.
However PowerCLI supports file operations such as copy, remove, get (download), and put (upload) files similar to Datastore Browser in the vSphere Client.
You can use Copy-DatastoreItem cmdlet for copy, download and upload operations over vmdk and *-flat.vmdk files but you should aware that this is manual file operation and does not perform any pre and post-checks like if VM is running or there are snapshots and delta disks

Full Datastore Browser functionality (dir, mv, cp, del) is supported by PowerCLI Datastore provider functionality. All you need to do is to browse vmstore:\ default drive in PowerShell console.

Regards,

Yasen Kalchev

PowerCLI Team

Yasen Kalchev, vSM Dev Team
Reply
0 Kudos