Hello,
I have this script:
$report = foreach($esx in (Get-VMHost | where{$_.PowerState -eq "PoweredOn"})){
foreach($lun in (Get-ScsiLun -VmHost $esx -LunType disk)){
Get-ScsiLunPath -ScsiLun $lun | `
Select @{N="Host";E={$esx.Name}},
@{N="LUN";E={$lun.CanonicalName}},
@{N="Target";E={
"{0:x} {1:x}" -f ($_.Extensiondata.Transport.NodeworldwideName,
$_.Extensiondata.Transport.PortworldwideName)
}}
}
}
$report | Export-Csv -path C:\Users\gemela\Desktop\SANLUN.csv
Where I get, hostname, Lun and target, I would like to get this WWN and WWP in HEX format like this previous post:
@{N='HBA Node WWN';E={$wwn = "{0:X}" -f $_.NodeWorldWideName; (0..7 | %{$wwn.Substring($_*2,2)}) -join ':'}},
@{N='HBA Node WWP';E={$wwp = "{0:X}" -f $_.PortWorldWideName; (0..7 | %{$wwp.Substring($_*2,2)}) -join ':'}}
Thanks
You mean something like this?
$report = foreach($esx in (Get-VMHost | where{$_.PowerState -eq "PoweredOn"})){
foreach($lun in (Get-ScsiLun -VmHost $esx -LunType disk)){
Get-ScsiLunPath -ScsiLun $lun | `
Select @{N="Host";E={$esx.Name}},
@{N="LUN";E={$lun.CanonicalName}},
@{N='WWN';E={$wwn = "{0:X}" -f $_.Extensiondata.Transport.NodeworldwideName; (0..7 | %{$wwn.Substring($_*2,2)}) -join ':'}},
@{N='WWP';E={$wwn = "{0:X}" -f $_.Extensiondata.Transport.PortworldwideName; (0..7 | %{$wwn.Substring($_*2,2)}) -join ':'}}
}
}
$report | Export-Csv -path C:\Users\gemela\Desktop\SANLUN.csv
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
Script work but for some reason I get different WWN / WWP, I compare with other script and make also check in vcenter,
With this I get correct data:
$cluster = Get-Cluster
$hosti = $cluster | Get-VMHost
$report333 = foreach ($esxi in $hosti) {
Get-VMHosthba -VMHost $esxi -type FibreChannel |
Select @{N="Host";E={$esxi.Name}},
@{N='HBA Node WWN';E={$wwn = "{0:X}" -f $_.NodeWorldWideName; (0..7 | %{$wwn.Substring($_*2,2)}) -join ':'}},
@{N='HBA Node WWP';E={$wwp = "{0:X}" -f $_.PortWorldWideName; (0..7 | %{$wwp.Substring($_*2,2)}) -join ':'}}
}
$report333 | Export-csv -Path C:\Users\xxgemela\Desktop\WWNTECO.csv –NoTypeInformation
Not sure what WWNs you are actually looking for, but when I check I get the values I see in the Web Client under Storage Adapters and Devices.
Perhaps you could include a screenshot of what you want to see.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I looking for WWN under Storage Adapters,
I have an example for one host
host10
This is what is vcenter and in the script
$report333 = foreach ($esxi in $hosti) {
Get-VMHosthba -VMHost $esxi -type FibreChannel |
Select @{N="Host";E={$esxi.Name}},
@{N='HBA Node WWN';E={$wwn = "{0:X}" -f $_.NodeWorldWideName; (0..7 | %{$wwn.Substring($_*2,2)}) -join ':'}},
@{N='HBA Node WWP';E={$wwp = "{0:X}" -f $_.PortWorldWideName; (0..7 | %{$wwp.Substring($_*2,2)}) -join ':'}}
}
20:00:2C:44:FD:E1:47:6A
20:00:2C:44:FD:E1:47:6B
This is what I get with the main script:
$report = foreach($esx in (Get-VMHost | where{$_.PowerState -eq "PoweredOn"})){
foreach($lun in (Get-ScsiLun -VmHost $esx -LunType disk)){
Get-ScsiLunPath -ScsiLun $lun | `
Select @{N="Host";E={$esx.Name}},
@{N="LUN";E={$lun.CanonicalName}},
@{N='WWN';E={$wwn = "{0:X}" -f $_.Extensiondata.Transport.NodeworldwideName; (0..7 | %{$wwn.Substring($_*2,2)}) -join ':'}},
@{N='WWP';E={$wwn = "{0:X}" -f $_.Extensiondata.Transport.PortworldwideName; (0..7 | %{$wwn.Substring($_*2,2)}) -join ':'}}
}
}
50:06:0E:80:07:E6:B4:31
50:06:0E:80:16:7B:FC:79
Hi LucD,
Sorry I check again in vSphere webclient , usually I check with app and I check only WWN under storage adapter, but now I see there is 'Target' in the paths,
So information is correct, it point LUN devices.
Thansk a lot