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
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
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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
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
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD if I run the script that you've suggested without the -Type "FibreChannel" parameter, does it will list all ?
You would see all HBA, but the Get-ScsiLun and Get-ScsiLunPath wouldn't make much sense for the non-FC HBA.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference