Automation

 View Only
  • 1.  SCSICanonicalName in output

    Posted Mar 22, 2021 01:35 PM

    Hi,

    I struggle to make friends with Get-View...

    Feeling dumber than usual, trying to add a SCSICanonicalName to the output of this script:

     

    $DiskInfo= @()

    foreach ($VMview in Get-VM SQLCUSTERVM001 | Get-View){

    foreach ($VirtualSCSIController in ($VMView.Config.Hardware.Device | where {$_.DeviceInfo.Label -match "SCSI Controller"})) {

    foreach ($VirtualDiskDevice in ($VMView.Config.Hardware.Device | where {$_.ControllerKey -eq $VirtualSCSIController.Key})) {

    $VirtualDisk = "" | Select VMname, SCSIController, DiskName, SCSI_ID, DeviceName, DiskFile, DiskSize

    $VirtualDisk.VMname = $VMview.Name

    $VirtualDisk.SCSIController = $VirtualSCSIController.DeviceInfo.Label

    $VirtualDisk.DiskName = $VirtualDiskDevice.DeviceInfo.Label

    $VirtualDisk.SCSI_ID = "$($VirtualSCSIController.BusNumber) : $($VirtualDiskDevice.UnitNumber)"

    $VirtualDisk.DeviceName = $VirtualDiskDevice.Backing.DeviceName

    $VirtualDisk.DiskFile = $VirtualDiskDevice.Backing.FileName

    $VirtualDisk.DiskSize = $VirtualDiskDevice.CapacityInKB * 1KB / 1GB

    $DiskInfo += $VirtualDisk

    }}}

    $DiskInfo | sort VMname, Diskname | Out-GridView

    #Export-Csv -Path 'd:DiskInfo.csv'

    # You can also use FT -AutoSize or Out-GridView if it helps

     

    I am sure this will take someone smarter than me about 30 seconds..?



  • 2.  RE: SCSICanonicalName in output

    Posted Mar 22, 2021 01:44 PM

    Not sure what exactly you mean by the CanonicalName in this case.
    Is this for RDM disks?



  • 3.  RE: SCSICanonicalName in output

    Posted Mar 22, 2021 01:53 PM

    By canonicalName I mean the naa.600xxxxxxxx

    And yes, these are RDM disks.



  • 4.  RE: SCSICanonicalName in output

    Posted Mar 22, 2021 02:01 PM

    Ok, in that case you could do something like the following.
    But note, that only RDM disks will show a CanonicalName



  • 5.  RE: SCSICanonicalName in output

    Posted Mar 22, 2021 02:13 PM

    Thank you, that works.

    I do, however, have one question:

    Do I have to choose if I want the $VirtualVisk.DeviceName to be in the format of the naa.600xxxxxx or vml.600xxxxx, or is there a way to do both?



  • 6.  RE: SCSICanonicalName in output
    Best Answer

    Posted Mar 22, 2021 02:28 PM

    The NAA (Network Addressing Authority identifier) is the preferred standard, and it is the name that comes from the storage device.
    It is also the field you will find in that CanonicalName property.
    The VML identifier is a legacy name generated by ESXi.

    Your Storage Admins probably want to know the NAA name.

    But you can have both in a report

      
    Further info on these names can be found in Storage Device Names and Identifiers



  • 7.  RE: SCSICanonicalName in output

    Posted Mar 22, 2021 02:29 PM

    Thank you!!