-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGet-HBAPathStatus.ps1
30 lines (27 loc) · 1.18 KB
/
Get-HBAPathStatus.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
29
30
#add input files
$VMHosts = get-cluster (Get-content C:\temp\cluster.txt) | Get-VMHost | ? { $_.ConnectionState -eq “Connected” } | Sort-Object -Property Name
$allresults= @()
$datastore = @()
foreach ($VMHost in $VMHosts) {
write-host “Working on host $VMHost”
[ARRAY]$HBAs = $VMHost | Get-VMHostHba -Type “FibreChannel”
$datastore = Get-Datastore -VMHost $VMHost
foreach ($HBA in $HBAs) {
$results = “” | select Name, Device, Cluster, ActiveP, DeadP, StandbyP , Datastore
$pathState = $HBA | Get-ScsiLun | ? { $_.Vendor -match “EMC”} | Get-ScsiLunPath | Group-Object -Property state
$results.Name = $VMHost.Name
$results.Device = $HBA.Device
$results.Cluster = $VMHost.Parent
$results.ActiveP = [INT]($pathState | ? { $_.Name -eq “Active”}).Count
$results.DeadP = [INT]($pathState | ? { $_.Name -eq “Dead”}).Count
$results.StandbyP = [INT]($pathState | ? { $_.Name -eq “Standby”}).Count
$results.Datastore = ([ARRAY]$datastore.name) -join ','
$allresults += $results
}
}
# Display the results in Gridview
$allresults | ft -AutoSize
# Or export to a CSV
$allresults | export-csv -Path C:\Temp\path.csv
C:\Temp\path.csv
disconnect-viserver -confirm:$false