Moving a hard drive with PowerCLI

I have a vm with several discs. I have create a new virtual machine, to attach a disk of the virtual machine first to this hard new using New-disk and passing the path to the vmdk.

The final bit, that I need is to remove the disc from the first virtual machine so that I can turn on the second. I can't work out how to do this with powerCLI, of course, it is quite easy using the GUI.

Any ideas?

Hello, Deanb61-

Decent docs: Yes, VMware support site has legitimate documentation: https://www.vmware.com/support/developer/PowerCLI/.  From there, you can see the documentation for the desired version of PowerCLI.  Of course, check the latest version the most up-to-date docs/features/etc.  Particular, Get-disk hard Ref is currently at http://pubs.vmware.com/vsphere-55/index.jsp#com.vmware.powercli.cmdletref.doc/Get-HardDisk.html.

You can find the name of the hard disk on the original VM with the first bit below and use that name, then remove the disk said.  Or, the second line of code just relies on the way to the store of data (filename) from the drive and deletes the given virtual machine disk.

## get the VM's disks and their names, so as to use its name laterGet-HardDisk -VM myVM | select Name,Filename,CapacityGB

## or, just get the hard disk with the given filename, and remove itGet-HardDisk -VM myVM | Where-Object {$_.Filename -eq "[myDStore0] myVM/myVM1.vmdk"} | Remove-HardDisk -DeletePermanently:$false

What to do for you?

Tags: VMware

Similar Questions

Maybe you are looking for