VMware Cloud Community
ganapa2000
Hot Shot
Hot Shot
Jump to solution

Unable to get WWPN details for particular VMhost

Hi,

I am trying to get the VMHost details using below script, but I am getting blank output

Please help

$myesx = VMhost1
$report = Get-VMHost $myesx |
ForEach-Object -Process {
$esxcli = Get-EsxCli -VMHost $_
$nic = Get-VMHostNetworkAdapter -VMHost $_ | Select -First 1 | select -ExpandProperty Name
$hba =Get-VMHostHBA -VMHost $_ -Type FibreChannel | where {$_.Status -eq "online"} | Select -First 1 |select -ExpandProperty Name
Get-VMHostHBA -VMHost $_ -Type FibreChannel | where {$_.Status -eq "online"} |
Select @{N="Host_Name";E={$($_.VMHost | Get-VMHostNetwork).HostName}},
@{N="Host_IP";E={($_.ExtensionData.Config.Network.Vnic | ? {$_.Device -eq "vmk0"}).Spec.Ip.IpAddress}},
@{N="ESXi_Version";E={$_.version}},
@{N='ESX_Build';E={$_.Build}},
@{N="Host_Manufacturer";E={$_.Manufacturer}},
@{N="Host_Model";E={$_.Model}},
@{N='Serial';E={(Get-EsxCli -VMHost $_).hardware.platform.get().SerialNumber}},
Device,Model,Status,
@{N="WWNN";E={((("{0:X}"-f $_.NodeWorldWideName).ToLower()) -replace "(\w{2})",'$1:').TrimEnd(':')}},
@{N="WWPN";E={((("{0:X}"-f $_.PortWorldWideName).ToLower()) -replace "(\w{2})",'$1:').TrimEnd(':')}},
@{N="nfnic_vendor";E={$esxcli.hardware.pci.list() | where {$hba -contains $_.VMKernelName} |Select -ExpandProperty VendorName }},
@{N="nfnic_driver";E={$esxcli.system.module.get("nfnic").version}},
@{N="nenic_driver";E={$esxcli.system.module.get("nenic").version}},
@{N="nenic_vendor";E={$esxcli.hardware.pci.list() | where {$nic -contains $_.VMKernelName} |Select -ExpandProperty VendorName }}
}
$report | ft -auto
$report | Export-Excel ".\myreport.xlsx" -AutoFilter -AutoSize

Labels (1)
0 Kudos
1 Solution

Accepted Solutions
ganapa2000
Hot Shot
Hot Shot
Jump to solution

LucD,

That worked, but I am now unable to export to excel as it is showing blank

$report = @()
Get-VMHost $myesx |
ForEach-Object -Process {
$esxcli = Get-EsxCli -VMHost $myesx
$nic = Get-VMHostNetworkAdapter -VMHost $_ | Select -First 1 | select -ExpandProperty Name
$hba =Get-VMHostHBA -VMHost $_ -Type FibreChannel | Select -First 1 |select -ExpandProperty Name
Get-VMHostHBA -VMHost $_ -Type FibreChannel |
Select @{N="Host_Name";E={$($_.VMHost | Get-VMHostNetwork).HostName}},
@{N="Host_IP";E={($_.VMHost.ExtensionData.Config.Network.Vnic | ? {$_.Device -eq "vmk0"}).Spec.Ip.IpAddress}},
@{N="ESXi_Version";E={$_.VMHost.version}},
@{N='ESX_Build';E={$_.VMHost.Build}},
@{N="Host_Manufacturer";E={$_.VMHost.Manufacturer}},
@{N="Host_Model";E={$_.VMHost.Model}},
@{N='Serial';E={$esxcli.hardware.platform.get().SerialNumber}},
Device,Model,Status,
@{N="WWNN";E={((("{0:X}"-f $_.NodeWorldWideName).ToLower()) -replace "(\w{2})",'$1:').TrimEnd(':')}},
@{N="WWPN";E={((("{0:X}"-f $_.PortWorldWideName).ToLower()) -replace "(\w{2})",'$1:').TrimEnd(':')}},
@{N="nfnic_vendor";E={$esxcli.hardware.pci.list() | where {$hba -contains $_.VMKernelName} |Select -ExpandProperty VendorName }},
@{N="nfnic_driver";E={$esxcli.system.module.get("nfnic").version}},
@{N="nenic_driver";E={$esxcli.system.module.get("nenic").version}},
@{N="nenic_vendor";E={$esxcli.hardware.pci.list() | where {$nic -contains $_.VMKernelName} |Select -ExpandProperty VendorName }}
}
$report | ft -auto
$report | Export-Excel $reportlocation -AutoFilter -AutoSize -WorksheetName nenic_nfnic_Detailed

View solution in original post

0 Kudos
6 Replies
LucD
Leadership
Leadership
Jump to solution

Is it only the WWPN properties that are missing?
Does that ESXi node have a FC HBA?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

LucD,

yes, ESXi has FC and seeing blank on below properties, rest are getting displayed

@{N="Host_IP";E={($_.ExtensionData.Config.Network.Vnic | ? {$_.Device -eq "vmk0"}).Spec.Ip.IpAddress}},
@{N="ESXi_Version";E={$_.version}},
@{N='ESX_Build';E={$_.Build}},
@{N="Host_Manufacturer";E={$_.Manufacturer}},
@{N="Host_Model";E={$_.Model}},
@{N='Serial';E={(Get-EsxCli -VMHost $_).hardware.platform.get().SerialNumber}},

 

 

0 Kudos
LucD
Leadership
Leadership
Jump to solution

You are doing the Select-Object after a Get-VMHostHBA, then you will not have those properties.
You could do

@{N="Host_IP";E={($_.VMHost.ExtensionData.Config.Network.Vnic | ? {$_.Device -eq "vmk0"}).Spec.Ip.IpAddress}},
@{N="ESXi_Version";E={$_.VMHost.version}},
@{N='ESX_Build';E={$_.VMHost.Build}},
@{N="Host_Manufacturer";E={$_.VMHost.Manufacturer}},
@{N="Host_Model";E={$_.VMHost.Model}},
@{N='Serial';E={(Get-EsxCli -VMHost $_.VMHost).hardware.platform.get().SerialNumber}},


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

LucD,

That worked, but I am now unable to export to excel as it is showing blank

$report = @()
Get-VMHost $myesx |
ForEach-Object -Process {
$esxcli = Get-EsxCli -VMHost $myesx
$nic = Get-VMHostNetworkAdapter -VMHost $_ | Select -First 1 | select -ExpandProperty Name
$hba =Get-VMHostHBA -VMHost $_ -Type FibreChannel | Select -First 1 |select -ExpandProperty Name
Get-VMHostHBA -VMHost $_ -Type FibreChannel |
Select @{N="Host_Name";E={$($_.VMHost | Get-VMHostNetwork).HostName}},
@{N="Host_IP";E={($_.VMHost.ExtensionData.Config.Network.Vnic | ? {$_.Device -eq "vmk0"}).Spec.Ip.IpAddress}},
@{N="ESXi_Version";E={$_.VMHost.version}},
@{N='ESX_Build';E={$_.VMHost.Build}},
@{N="Host_Manufacturer";E={$_.VMHost.Manufacturer}},
@{N="Host_Model";E={$_.VMHost.Model}},
@{N='Serial';E={$esxcli.hardware.platform.get().SerialNumber}},
Device,Model,Status,
@{N="WWNN";E={((("{0:X}"-f $_.NodeWorldWideName).ToLower()) -replace "(\w{2})",'$1:').TrimEnd(':')}},
@{N="WWPN";E={((("{0:X}"-f $_.PortWorldWideName).ToLower()) -replace "(\w{2})",'$1:').TrimEnd(':')}},
@{N="nfnic_vendor";E={$esxcli.hardware.pci.list() | where {$hba -contains $_.VMKernelName} |Select -ExpandProperty VendorName }},
@{N="nfnic_driver";E={$esxcli.system.module.get("nfnic").version}},
@{N="nenic_driver";E={$esxcli.system.module.get("nenic").version}},
@{N="nenic_vendor";E={$esxcli.hardware.pci.list() | where {$nic -contains $_.VMKernelName} |Select -ExpandProperty VendorName }}
}
$report | ft -auto
$report | Export-Excel $reportlocation -AutoFilter -AutoSize -WorksheetName nenic_nfnic_Detailed

0 Kudos
LucD
Leadership
Leadership
Jump to solution

That is because you changed

$report = Get-VMHost $myesx |

into

Get-VMHost $myesx |


Nothing is captured in $report that way


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

Thank you very much...that worked... 🙂

0 Kudos