Skip to content

Commit 2e81ecd

Browse files
authored
Merge pull request #1 from dstamen/master
Add scripts to repo
2 parents fc22dc4 + fa464a2 commit 2e81ecd

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

Get-FibreChannelPaths.ps1

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# PowerCLI Script for retrieving Fibre Channel Path Status from ESXi Hosts
2+
# @davidstamen
3+
# https://davidstamen.com
4+
5+
$vcname = "vc.lab.local"
6+
$vcuser = "administrator@vsphere.local"
7+
$vcpass = "Password1!"
8+
$clustername = "Cluster01"
9+
10+
$VC = Connect-VIServer $vcname -User $vcuser -Password $vcpass -WarningAction SilentlyContinue
11+
12+
13+
$VMHosts = Get-Cluster $clustername -Server $VC | Get-VMHost | Where-Object { $_.ConnectionState -eq "Connected" } | Sort-Object -Property Name
14+
$results= @()
15+
16+
foreach ($VMHost in $VMHosts) {
17+
[ARRAY]$HBAs = $VMHost | Get-VMHostHba -Type "FibreChannel"
18+
19+
foreach ($HBA in $HBAs) {
20+
$pathState = $HBA | Get-ScsiLun | Get-ScsiLunPath | Group-Object -Property state
21+
$pathStateActive = $pathState | Where-Object { $_.Name -eq "Active"}
22+
$pathStateDead = $pathState | Where-Object { $_.Name -eq "Dead"}
23+
$pathStateStandby = $pathState | Where-Object { $_.Name -eq "Standby"}
24+
$results += "{0},{1},{2},{3},{4},{5}" -f $VMHost.Name, $HBA.Device, $VMHost.Parent, [INT]$pathStateActive.Count, [INT]$pathStateDead.Count, [INT]$pathStateStandby.Count
25+
}
26+
27+
}
28+
ConvertFrom-Csv -Header "VMHost","HBA","Cluster","Active","Dead","Standby" -InputObject $results | Format-Table -AutoSize

Get-IScsiPaths.ps1

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# PowerCLI Script for retrieving iSCSI Path Status from ESXi Hosts
2+
# @davidstamen
3+
# https://davidstamen.com
4+
5+
$vcname = "vc.lab.local"
6+
$vcuser = "administrator@vsphere.local"
7+
$vcpass = "Password1!"
8+
$clustername = "Cluster01"
9+
10+
$VC = Connect-VIServer $vcname -User $vcuser -Password $vcpass -WarningAction SilentlyContinue
11+
$VMHosts = Get-Cluster $clustername -Server $VC | Get-VMHost | Where-Object { $_.ConnectionState -eq "Connected" } | Sort-Object -Property Name
12+
13+
$results= @()
14+
15+
foreach ($VMHost in $VMHosts) {
16+
[ARRAY]$HBAs = $VMHost | Get-VMHostHba -Type "IScsi"
17+
18+
foreach ($HBA in $HBAs) {
19+
$pathState = $HBA | Get-ScsiLun | Get-ScsiLunPath | Group-Object -Property state
20+
$pathStateActive = $pathState | Where-Object { $_.Name -eq "Active"}
21+
$pathStateDead = $pathState | Where-Object { $_.Name -eq "Dead"}
22+
$pathStateStandby = $pathState | Where-Object { $_.Name -eq "Standby"}
23+
$results += "{0},{1},{2},{3},{4},{5}" -f $VMHost.Name, $HBA.Device, $VMHost.Parent, [INT]$pathStateActive.Count, [INT]$pathStateDead.Count, [INT]$pathStateStandby.Count
24+
}
25+
26+
}
27+
ConvertFrom-Csv -Header "VMHost","HBA","Cluster","Active","Dead","Standby" -InputObject $results | Format-Table -AutoSize

0 commit comments

Comments
 (0)