I would like to add a shared virtual disk to a second VM which is already attached to a first VM. They will have shared access to the disk, via SCSI controllers set to virtual bus sharing.
This works fine via the vCenter GUI, but I'd like to do it via PoweCLI.
I can't find a way to attach a new SCSI controller to the second VM, without passing in the existing hard disk as an argument to the new-scsicontroller
cmdlet. Unfortunately, this results in a new SCSI controller on the first VM, not the second VM.
Any ideas how to do this with the vSphere API, or other techniques?
The best way to find get PowerCLI code for something you can't figure out is with Onyx: http://labs.vmware.com/flings/onyx
The following works in PowerCLI on vSphere 5.5. As written it will create a new 1GB drive on a new LSI Logic SAS storage controller with SCSI Bus Sharing in Virtual mode on server1 and add that same VMDK as a new disk on a new LSI Logic SAS storage controller with SCSI Bus Sharing in Virtual mode on server2 and server3. You could modify it to query for an existing SCSI controller and add it to that controller instead.