Automation

 View Only
  • 1.  Paths report not matching gui

    Posted Apr 24, 2017 06:42 PM

    All,

    We have a script we were planning to use to find dead, standby, and active paths, but it doesn't seem to match up to the gui every time.  Any idea why?  Is this cmdlet out of date?

    $results= @()

    foreach ($VMHost in $VMHosts) {

    ##   Get-VMHostStorage -RescanAllHba -VMHost $VMHost | Out-Null

    [ARRAY]$HBAs = $VMHost | Get-VMHostHba -Type "FibreChannel"

          foreach ($HBA in $HBAs) {

        $pathState = $HBA | Get-ScsiLun | Get-ScsiLunPath | Group-Object -Property state

        $pathStateActive = $pathState | ? { $_.Name -eq "Active"}

        $pathStateDead = $pathState | ? { $_.Name -eq "Dead"}

        $pathStateStandby = $pathState | ? { $_.Name -eq "Standby"}

        $results += "{0},{1},{2},{3},{4},{5}" -f $VMHost.Name, $HBA.Device, $VMHost.Parent, [INT]$pathStateActive.Count, [INT]$pathStateDead.Count, [INT]$pathStateStandby.Count

        }

    }

    ConvertFrom-Csv -Header "VMHost","HBA","Cluster","Active","Dead","Standby" -InputObject $results | Ft -AutoSize



  • 2.  RE: Paths report not matching gui

    Posted Apr 24, 2017 07:32 PM

    The Get-ScsiLunPath returns the paths to a specific LUN over all HBA.

    In the vSphere Client (or Web Client), you see the paths for a specific HBA.

    You can adapt the script like this

    $results= @()

    foreach ($VMHost in $VMHosts) {

    ##   Get-VMHostStorage -RescanAllHba -VMHost $VMHost | Out-Null

    [ARRAY]$HBAs = $VMHost | Get-VMHostHba -Type "FibreChannel"

          foreach ($HBA in $HBAs) {

            $pathState = $HBA | Get-ScsiLun | Get-ScsiLunPath | where{$_.Name -match $HBA.Device} | Group-Object -Property state

            $pathStateActive = $pathState | ? { $_.Name -eq "Active"}

            $pathStateDead = $pathState | ? { $_.Name -eq "Dead"}

            $pathStateStandby = $pathState | ? { $_.Name -eq "Standby"}

            $results += "{0},{1},{2},{3},{4},{5}" -f $VMHost.Name, $HBA.Device, $VMHost.Parent, [INT]$pathStateActive.Count, [INT]$pathStateDead.Count, [INT]$pathStateStandby.Count

          }

    }

    ConvertFrom-Csv -Header "VMHost","HBA","Cluster","Active","Dead","Standby" -InputObject $results | Ft -AutoSize



  • 3.  RE: Paths report not matching gui

    Posted Apr 24, 2017 08:27 PM

      I was trying to figure out what I was missing. It goes through each HBA with the loop though?  It does show the correct paths for some hosts, but other it doesn't and it is strange.  I can provide an example if needed.

    I ran it and its showing 0 for everything?  It is trying to match name, but that gives a device name.

    VMHost             HBA    Cluster     Active Dead Standby

    ------                                    ---    -------     ------ ---- -------

    appvmware442 vmhba1 CLU23 0      0    0

    appvmware442 vmhba2 CLU23 0      0    0



  • 4.  RE: Paths report not matching gui

    Posted Apr 25, 2017 05:06 AM

    You would need to check if the HBA Device property is present in the Name of the Lun path

    Get-VMHostHba -Type "FibreChannel" | Select Name,Device

    Get-VMHostHba -Type "FibreChannel" | Get-ScsiLun | Get-ScsiLunPath | Select Name,State



  • 5.  RE: Paths report not matching gui

    Posted Apr 26, 2017 01:48 AM

    LucD if I run the script that you've suggested without the -Type "FibreChannel"   parameter, does it will list all ?



  • 6.  RE: Paths report not matching gui

    Posted Apr 26, 2017 05:41 AM

    You would see all HBA, but the Get-ScsiLun and Get-ScsiLunPath wouldn't make much sense for the non-FC HBA.