PowerCLI - add shared hard disk to vm, using existing scsi controller

6,343

The best way to find get PowerCLI code for something you can't figure out is with Onyx: http://labs.vmware.com/flings/onyx

Share:
6,343

Related videos on Youtube

sjw
Author by

sjw

Updated on September 18, 2022

Comments

  • sjw
    sjw over 1 year

    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?

    • sjw
      sjw over 12 years
      Oh, I figured it out. I needed to add all the disks using new-harddisk on the second vm, and accumulating the objects in a variable. then go back and use the new-scsicontroller cmdlet on the second vm passing in the array of shared disks as a paramater.
  • ewwhite
    ewwhite over 12 years
    This is a very good tip.