PowerCLI

 View Only
  • 1.  Find Datastore name by VM disk SCSI number

    Posted Dec 11, 2012 03:56 PM

    I wonder if there is a way to write a script that finds Datastore name if I have VM name and VM disk SCSI number (0:2, for example)?

    Thanks a lot!



  • 2.  RE: Find Datastore name by VM disk SCSI number

    Posted Dec 11, 2012 04:38 PM

    Try something like this

    Get-VM | Get-HardDisk | 
    Select
    @{N="VM";E={$_.Parent.Name}}, Name,
    @
    {N="Datastore";E={$_.Datastore}},
    @{N="SCSI Id";E={[string](Get-ScsiController -Harddisk $_).ExtensionData.BusNumber + ":" + [string]$_.UnitNumber}}


  • 3.  RE: Find Datastore name by VM disk SCSI number

    Posted Dec 11, 2012 04:48 PM

    Luc,

    Thanks a lot!

    However, when I am running your script it does not seem grabing "UnitNumber" (SCSI Id always 0: ) and Datastore field is always blank as well.

    Any suggestions?

    Thanks,

    qwert



  • 4.  RE: Find Datastore name by VM disk SCSI number

    Posted Dec 11, 2012 04:59 PM

    Which PowerCLI version are your running ?

    Do a

    Get-PowerCLIVersion

    And your VMs are on VMFS datastores, not NFS I assume ?



  • 5.  RE: Find Datastore name by VM disk SCSI number

    Posted Dec 11, 2012 05:30 PM

    I have VMware vSphere PowerCLI 5.0 build 435427

    Actually, I am using VMs on both storage types - VMFS and NFS.  Is it matter?

    Thank you!



  • 6.  RE: Find Datastore name by VM disk SCSI number

    Posted Dec 11, 2012 05:38 PM

    Afaik I does, on a NFS datastore that script I gave will not work.

    Not that it matters in this case, but you should perhaps consider upgarding to PowerCLI 5.1