Automation

 View Only
  • 1.  Unable to get WWPN details for particular VMhost

    Posted Sep 14, 2021 05:45 AM

    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



  • 2.  RE: Unable to get WWPN details for particular VMhost

    Posted Sep 14, 2021 06:10 AM

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



  • 3.  RE: Unable to get WWPN details for particular VMhost

    Posted Sep 14, 2021 07:04 AM

    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}},

     

     



  • 4.  RE: Unable to get WWPN details for particular VMhost

    Posted Sep 14, 2021 07:08 AM

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



  • 5.  RE: Unable to get WWPN details for particular VMhost
    Best Answer

    Posted Sep 14, 2021 08:09 AM

    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



  • 6.  RE: Unable to get WWPN details for particular VMhost

    Posted Sep 14, 2021 08:24 AM

    That is because you changed

    into


    Nothing is captured in $report that way



  • 7.  RE: Unable to get WWPN details for particular VMhost

    Posted Sep 14, 2021 09:02 AM

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