Posted in
Windows Powershell,
Windows Server |
No Comment | 3,159 views | 30/06/2014 17:32
You can use following script to get Port and Fabric WWN information from FCinfo via PowerShell.
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
| # Get FCInfo Details
$FcToolCmd = "C:\StorageTools\fcinfo\fcinfo.exe /details"
# Create WWN Array
$WWNArray = @()
# Create Hash Table
$WWNInformation = @{}
# Port WWN Information
$FabricDetails = Invoke-Expression $FcToolCmd | Where {$_ -match "port_wwn"}
foreach ($FabricInfo in $FabricDetails)
{
# Get Port WWN
$FabricRegex = $FabricInfo -match "\b\S{2}\:\S{2}\:\S{2}\:\S{2}\:\S{2}\:\S{2}\:\S{2}\:\S{2}\b"
$PortWWN = $Matches[0]
# Add Hash Table
$WWNInformation."$PortWWN" = "NULL"
# Add WWN Array
$WWNArray += $PortWWN
}
# Fabric Index
$FabricIndex = 0;
# Fabric WWN Information
$FabricDetails = Invoke-Expression $FcToolCmd | Where {$_ -match "fabric"}
foreach ($FabricInfo in $FabricDetails)
{
# Get Fabric WWN
$FabricRegex = $FabricInfo -match "\b\S{2}\:\S{2}\:\S{2}\:\S{2}\:\S{2}\:\S{2}\:\S{2}\:\S{2}\b"
$FabricWWN = $Matches[0]
# Get Port WWN
$PortWWN = $WWNArray[$FabricIndex]
# Add Hash Table
$WWNInformation."$PortWWN" = "$FabricWWN"
# Update Fabric Index
$FabricIndex++
}
# Output Results
$WWNInformation |
# Get FCInfo Details
$FcToolCmd = "C:\StorageTools\fcinfo\fcinfo.exe /details"
# Create WWN Array
$WWNArray = @()
# Create Hash Table
$WWNInformation = @{}
# Port WWN Information
$FabricDetails = Invoke-Expression $FcToolCmd | Where {$_ -match "port_wwn"}
foreach ($FabricInfo in $FabricDetails)
{
# Get Port WWN
$FabricRegex = $FabricInfo -match "\b\S{2}\:\S{2}\:\S{2}\:\S{2}\:\S{2}\:\S{2}\:\S{2}\:\S{2}\b"
$PortWWN = $Matches[0]
# Add Hash Table
$WWNInformation."$PortWWN" = "NULL"
# Add WWN Array
$WWNArray += $PortWWN
}
# Fabric Index
$FabricIndex = 0;
# Fabric WWN Information
$FabricDetails = Invoke-Expression $FcToolCmd | Where {$_ -match "fabric"}
foreach ($FabricInfo in $FabricDetails)
{
# Get Fabric WWN
$FabricRegex = $FabricInfo -match "\b\S{2}\:\S{2}\:\S{2}\:\S{2}\:\S{2}\:\S{2}\:\S{2}\:\S{2}\b"
$FabricWWN = $Matches[0]
# Get Port WWN
$PortWWN = $WWNArray[$FabricIndex]
# Add Hash Table
$WWNInformation."$PortWWN" = "$FabricWWN"
# Update Fabric Index
$FabricIndex++
}
# Output Results
$WWNInformation
That will give you a hashtable as a result, so you can see details.