-
Notifications
You must be signed in to change notification settings - Fork 8
/
Get-FibreChannelPaths.ps1
28 lines (21 loc) · 1.19 KB
/
Get-FibreChannelPaths.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# PowerCLI Script for retrieving Fibre Channel Path Status from ESXi Hosts
# @davidstamen
# https://davidstamen.com
$vcname = "vc.lab.local"
$vcuser = "[email protected]"
$vcpass = "Password1!"
$clustername = "Cluster01"
$VC = Connect-VIServer $vcname -User $vcuser -Password $vcpass -WarningAction SilentlyContinue
$VMHosts = Get-Cluster $clustername -Server $VC | Get-VMHost | Where-Object { $_.ConnectionState -eq "Connected" } | Sort-Object -Property Name
$results= @()
foreach ($VMHost in $VMHosts) {
[ARRAY]$HBAs = $VMHost | Get-VMHostHba -Type "FibreChannel"
foreach ($HBA in $HBAs) {
$pathState = $HBA | Get-ScsiLun | Get-ScsiLunPath | Group-Object -Property state
$pathStateActive = $pathState | Where-Object { $_.Name -eq "Active"}
$pathStateDead = $pathState | Where-Object { $_.Name -eq "Dead"}
$pathStateStandby = $pathState | Where-Object { $_.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 | Format-Table -AutoSize