Hello,
I check this discussion
I use this one:
$cluster = get-cluster
$hosti = get-Cluster $cluster | Get-VMHost
$report333 = @()
foreach ($esxi in $hosti) {
$report333 +=Get-VMHosthba -VMHost $esxi -type FibreChannel |
Select @{N="Host";E={$esxi.Name}},
@{N="HBA Node WWN";E={"{0:x}" -f $_.NodeWorldWideName}},
@{N="HBA Port WWP";E={"{0:x}" -f $_.PortWorldWideName}}
}
$report333 | Export-csv -Path C:\Users\gemela\Desktop\WWNTECO.csv –NoTypeInformation
And I get this format: "200024827aaf84f2","1000289et53f84f2"
Is possible to get format like: 20:00:28:22:4a:af:84:f3 10:10:28:02:4a:af:84:f2
Thanks
Try like this
$wwn = "200024827aaf84f2"
(0..7 | %{$wwn.Substring($_*2,2)}) -join ':'
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
Is possible to include in the script to get directly in csv file with this format?
Try like this
$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\gemela\Desktop\WWNTECO.csv –NoTypeInformation
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Script looks like works, but I got wrong WWN/WWP.
Oops, I forgot the conversion to hex.
The code above is updated
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Perfect, it work
Thanks a lot LucD.
Thank you Luc. script worked perfectly!
Try like this
$cluster = Get-Cluster
$hosti = $cluster | Get-VMHost
$report333 = foreach ($esxi in $hosti) {
Get-VMHosthba -VMHost $esxi -type FibreChannel | where{$_.STatus -eq 'online'} |
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\gemela\Desktop\WWNTECO.csv –NoTypeInformation
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks LucD,
Works like Charm!
That is the format operator, it is used to format string output
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
thank you Luc
I tried the script it worked, but it didn't give me the hba name, it just gave me the wwpn, could you please help me here
Just add the Name on the Select-Object
$cluster = Get-Cluster
$hosti = $cluster | Get-VMHost
$report333 = foreach ($esxi in $hosti) {
Get-VMHosthba -VMHost $esxi -type FibreChannel | where{$_.Status -eq 'online'} |
Select @{N="Host";E={$esxi.Name}},
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\gemela\Desktop\WWNTECO.csv –NoTypeInformation
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference