VMware Cloud Community
lorried82
Enthusiast
Enthusiast

Path Status for Storage

I am looking to get a report that will check the status of the HBA's. I have seen a lot out there but I can't get it to look like what I want.

I want to be able to run the report by either cluster, datacenter, or all hosts. I also want to have the option filter out only DEAD paths.

I would like the output to be basically be the information in the image below where it will summarize by Hostname and HBA the Targets, Devices, Paths then list out the Runtime name, Target, Lun and Status

Is this possible?

much appreciation with any help!

Tags (2)
0 Kudos
4 Replies
RAJ_RAJ
Expert
Expert

Hi ,

Below script will give you detailed information

#Connect to vCenter Server

Connect-VIServer "vCenterServer"

#Get list of ESXi Hosts

$esxihosts = Get-VMHost

$i=0

$data = ForEach ($esxi in $esxihosts) {

  $i++

  Write-Progress -Activity "Scanning hosts" -Status ("Host: {0}" -f $esxi.Name) -PercentComplete ($i/$esxihosts.count*100) -Id 0

  $hbas = $esxi | Get-VMHostHba

  $j=0

  ForEach ($hba in $hbas) {

  $j++

  Write-Progress -Activity "Scanning HBAs" -Status ("HBA: {0}" -f $hba.Device) -PercentComplete ($j/$hbas.count*100) -Id 1

  $scsiluns = $hba | Get-ScsiLun

  $k=0

  ForEach ($scsilun in $scsiluns) {

  $k++

  Write-Progress -Activity "Scanning Luns" -Status ("Lun: {0}" -f $scsilun.CanonicalName) -PercentComplete ($k/$scsiluns.count*100) -Id 2

  $scsipaths = $scsilun | Get-Scsilunpath

  $l=0

  ForEach ($scsipath in $scsipaths) {

  $l++

  Write-Progress -Activity "Scanning Paths" -Status ("Path: {0}" -f $scsipath.Name) -PercentComplete ($l/$scsipaths.count*100) -Id 3

  New-Object PSObject -Property @{

  Host = $esxi.name

  HBAName = $scsilun.RuntimeName

  PathSelectionPolicy = $scsilun.MultiPathPolicy

  Status = $scsipath.state

  Source = "{0}" -f ((("{0:x}" -f $hba.PortWorldWideName) -split '([a-f0-9]{2})' | where {$_}) -Join ":")

  Target = $scsipath.SanId

  LUN = (($scsilun.RunTimeName -Split "L")[1] -as [Int])

  Path = $scsipath.LunPath

  }

  }

  }

  }

}

$data | Export-Csv -NoTypeInformation 'C:\file.csv'

RAJESH RADHAKRISHNAN VCA -DCV/WM/Cloud,VCP 5 - DCV/DT/CLOUD, ,VCP6-DCV, EMCISA,EMCSA,MCTS,MCPS,BCFA https://ae.linkedin.com/in/rajesh-radhakrishnan-76269335 Mark my post as "helpful" or "correct" if I've helped resolve or answered your query!
0 Kudos
lorried82
Enthusiast
Enthusiast

Thanks. I was hoping to be able to filter out by status that equals dead - is there a way to get that added in? I was able to add the option to get it to pull by cluster.

Thanks

0 Kudos
lorried82
Enthusiast
Enthusiast

reposting this to look for some help on this. I am still looking to get this script completed.

Any thoughts?LucD

0 Kudos
LucD
Leadership
Leadership

Did you see this one Re: command to find dead lun paths

The example starts from a single ESXi node, but you could do Get-Cluster | Get-VMHost


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos