-
Notifications
You must be signed in to change notification settings - Fork 1
/
Get-HBAWin.ps1
51 lines (43 loc) · 1.83 KB
/
Get-HBAWin.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
Invoke-Expression (Invoke-WebRequest https://raw.githubusercontent.com/ed7hunt/PowerShell-and-PowerGUI/master/update_powershell.ps1).Content
# Written by Edward Hunt, DOR Infrastructure Supervisor
# Purpose: This script will list the WWNs from HBA info which is needed for adding SAN Luns.
# November 19, 2018
# Directions:
# 1) Download this PowerShell script to retrieve the Fiber-Channel WWNs for your Window's Server.
# 2) Run the script with your administrator account in PowerShell ISE.
# 3) The output will be located on the server's desktop in CSV format.
param(
[String[]]$ComputerName = $ENV:ComputerName,
[Switch]$LogOffline
)
$ComputerName | ForEach-Object {
try {
$Computer = $_
$Params = @{
Namespace = 'root\WMI'
class = 'MSFC_FCAdapterHBAAttributes'
ComputerName = $Computer
ErrorAction = 'Stop'
}
Get-WmiObject @Params | ForEach-Object {
$hash=@{
ComputerName = $_.__SERVER
NodeWWN = (($_.NodeWWN) | ForEach-Object {"{0:X2}" -f $_}) -join ":"
Active = $_.Active
DriverName = $_.DriverName
DriverVersion = $_.DriverVersion
FirmwareVersion = $_.FirmwareVersion
Model = $_.Model
ModelDescription = $_.ModelDescription
}
New-Object psobject -Property $hash
}#Foreach-Object(Adapter)
}#try
catch {
Write-Warning -Message $_
if ($LogOffline)
{
"$Computer is offline or not supported" >> "C:$env:HOMEPATH\Desktop\Offline.txt"
}
}
} | Export-Csv -Path C:$env:HOMEPATH\Desktop\WWN_output.csv -Confirm #Foreach-Object(Computer)