The advantage of below powerCLI is that oneliner shows as well SerialNumber (for example Dell/HP tags &#8211; very useful to find your esxi server in Datacenter physically ) Get-VMHost |Select-Object Name,NetworkInfo,Manufacturer,Model,ProcessorType, ConnectionState, PowerState, NumCpu, MemoryTotalGB, Version, Build, MaxEVCMode, @{N="SerialNumber";E={(Get-VMHostHardware -vmhost $_).SerialNumber}} | Export-Csv -notypeinformation -Path c:\temp\all-vmhosts.csv or more detailed report: .'C:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1' connect-viserver vcsa.itforce.local function Get-VMHostWSManInstance { param ( [Parameter(Mandatory=$TRUE,HelpMessage="VMHosts to probe")] [VMware.VimAutomation.Client20.VMHostImpl[]] $VMHosts, [Parameter(Mandatory=$TRUE,HelpMessage="Class Name")] [string] $class, [switch] $ignoreCertFailures, [System.Management.Automation.PSCredential] $credential=$null ) $omcBase = "http://schema.omc-project.org/wbem/wscim/1/cim-schema/2/" $dmtfBase = "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/" $vmwareBase = "http://schemas.vmware.com/wbem/wscim/1/cim-schema/2/" if ($ignoreCertFailures)  <span><a href="https://www.itforce.mn/index.php/2019/01/31/how-to-get-detailed-info-for-all-esxi/" class="readmore">Continue reading &rarr;</a></span>{"id":1412,"date":"2019-01-31T20:48:11","date_gmt":"2019-01-31T12:48:11","guid":{"rendered":"https:\/\/www.itforce.mn\/?p=1412"},"modified":"2021-05-13T16:30:54","modified_gmt":"2021-05-13T08:30:54","slug":"how-to-get-detailed-info-for-all-esxi","status":"publish","type":"post","link":"https:\/\/www.itforce.mn\/index.php\/2019\/01\/31\/how-to-get-detailed-info-for-all-esxi\/","title":{"rendered":"How to get detailed info for all esxi into csv or Excel file"},"content":{"rendered":"<p>The advantage of below powerCLI is that oneliner shows as well SerialNumber (for example Dell\/HP tags &#8211; very useful to find your esxi server in Datacenter physically )<\/p>\n<pre>Get-VMHost |Select-Object Name,NetworkInfo,Manufacturer,Model,ProcessorType, ConnectionState, PowerState, NumCpu, MemoryTotalGB, Version, Build, MaxEVCMode, @{N=\"SerialNumber\";E={(Get-VMHostHardware -vmhost $_).SerialNumber}} | Export-Csv -notypeinformation -Path c:\\temp\\all-vmhosts.csv \r\n<\/pre>\n<p>or more detailed report:<\/p>\n<pre>.'C:\\Program Files (x86)\\VMware\\Infrastructure\\PowerCLI\\Scripts\\Initialize-PowerCLIEnvironment.ps1'\r\nconnect-viserver vcsa.itforce.local\r\n\r\nfunction Get-VMHostWSManInstance {\r\n        param (\r\n        [Parameter(Mandatory=$TRUE,HelpMessage=\"VMHosts to probe\")]\r\n        [VMware.VimAutomation.Client20.VMHostImpl[]]\r\n        $VMHosts,\r\n \r\n        [Parameter(Mandatory=$TRUE,HelpMessage=\"Class Name\")]\r\n        [string]\r\n        $class,\r\n \r\n        [switch]\r\n        $ignoreCertFailures,\r\n \r\n        [System.Management.Automation.PSCredential]\r\n        $credential=$null\r\n        )\r\n \r\n        $omcBase = \"http:\/\/schema.omc-project.org\/wbem\/wscim\/1\/cim-schema\/2\/\"\r\n        $dmtfBase = \"http:\/\/schemas.dmtf.org\/wbem\/wscim\/1\/cim-schema\/2\/\"\r\n        $vmwareBase = \"http:\/\/schemas.vmware.com\/wbem\/wscim\/1\/cim-schema\/2\/\"\r\n \r\n        if ($ignoreCertFailures) {\r\n                $option = New-WSManSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck\r\n        } else {\r\n                $option = New-WSManSessionOption\r\n        }\r\n        foreach ($H in $VMHosts) {\r\n                if ($credential -eq $null) {\r\n                        $hView = $H | Get-View -property Value\r\n                        $ticket = $hView.AcquireCimServicesTicket()\r\n                        $password = convertto-securestring $ticket.SessionId -asplaintext -force\r\n                        $credential = new-object -typename System.Management.Automation.PSCredential -argumentlist $ticket.SessionId, $password\r\n                }\r\n                $uri = \"https`:\/\/\" + $h.Name + \"\/wsman\"\r\n                if ($class -cmatch \"^CIM\") {\r\n                        $baseUrl = $dmtfBase\r\n                } elseif ($class -cmatch \"^OMC\") {\r\n                        $baseUrl = $omcBase\r\n                } elseif ($class -cmatch \"^VMware\") {\r\n                        $baseUrl = $vmwareBase\r\n                } else {\r\n                        throw \"Unrecognized class\"\r\n                }\r\n                Get-WSManInstance -Authentication basic -ConnectionURI $uri -Credential $credential -Enumerate -Port 443 -UseSSL -SessionOption $option -ResourceURI \"$baseUrl\/$class\"\r\n        }\r\n}\r\n \r\n# Examples (make sure you are connected to an ESX server.)\r\n# Get-VMHostWSManInstance -VMHost (Get-VMHost) -class CIM_Fan -ignoreCertFailures\r\n# Get-VMHostWSManInstance -VMHost (Get-VMHost) -class VMware_Role -ignoreCertFailures\r\n# Get-VMHostWSManInstance -VMHost (Get-VMHost) -class OMC_Card -ignoreCertFailures\r\n# See http`:\/\/www.vmware.com\/support\/developer\/cim-sdk\/smash\/u2\/ga\/apirefdoc\/ for a list of classes.\r\n\r\nfunction moguy-esxi\r\n\r\n{\r\n\r\n$filename = \"vmware-esxi-\" + (get-date).ToString('yyyy-MMMM-dd')\r\n\r\nGet-VMHost |Select-Object Name,NetworkInfo,@{N=\"SerialNumber\";E={(Get-VMHostHardware -vmhost $_).SerialNumber}}, `\r\n@{ N=\"OutOfBandIP\";E={(Get-VMHostWSManInstance -VMHost $_ -ignoreCertFailures -class OMC_IPMIIPProtocolEndpoint).IPv4Address}},`\r\nManufacturer,Model,`\r\n@{N=\"vmotionIP\";E={(get-view $_.id).config.vmotion.ipconfig.ipaddress}},`\r\nProcessorType, ConnectionState, PowerState, NumCpu,`\r\n@{N=\"Cores\/CPU\";E={$_.Extensiondata.Summary.Hardware.NumCpuCores\/$_.Extensiondata.Summary.Hardware.NumCpuPkgs}}, `\r\nMemoryTotalGB, Version, Build, MaxEVCMode,`\r\n@{N=\"Lockdown\";E={$_.Extensiondata.Config.adminDisabled}},@{N=\"site\";E={$_.customfields.item(\"00-site\")}}, @{N=\"rack\";E={$_.customfields.item(\"01-rack\")}}, @{N=\"position\";E={$_.customfields.item(\"02-rack-position\")}},`\r\nParent, @{N=\"iso-image\";E={((get-view ($_.ExtensionData.ConfigManager.ImageConfigManager)).HostImageConfigGetProfile()).name}},`\r\n@{N=\"wwns\";E={[string]::join(\",\",(Get-VMHostHBA -vmhost $_ -Type FibreChannel | select-object @{N=\"WWN\";E={\"{0:X}\"-f$_.PortWorldWideName}} | Select-Object -ExpandProperty wwn))}}, `\r\n@{N=\"10G\";E={[string]::join(\",\", ((Get-EsxCli -VMHost $_ ).network.nic.list()|where {($_.Description -like \"*10G*\") -or ($_.Description -like \"*10 G*\")} | Select-Object -ExpandProperty Description))}}`\r\n| Export-Csv -notypeinformation -Path c:\\temp\\$filename.csv\r\n\r\n}\r\n\r\nmoguy-esxi\r\n\r\n<\/pre>\n<p>ps<br \/>\nThe above script implys that you&#8217;ve create custom fields for all your esxi named: &#8220;00-site&#8221;,&#8221;01-rack&#8221;, &#8220;02-rack-position&#8221;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.itforce.mn\/wp-content\/uploads\/2019\/01\/esxi.png\" alt=\"\" width=\"1875\" height=\"505\" class=\"alignnone size-full wp-image-1619\" \/><\/p>\n","protected":false},"excerpt":{"rendered":null,"protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-1412","post","type-post","status-publish","format-standard","hentry","category-powercli"],"_links":{"self":[{"href":"https:\/\/www.itforce.mn\/index.php\/wp-json\/wp\/v2\/posts\/1412","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.itforce.mn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.itforce.mn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.itforce.mn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.itforce.mn\/index.php\/wp-json\/wp\/v2\/comments?post=1412"}],"version-history":[{"count":12,"href":"https:\/\/www.itforce.mn\/index.php\/wp-json\/wp\/v2\/posts\/1412\/revisions"}],"predecessor-version":[{"id":1641,"href":"https:\/\/www.itforce.mn\/index.php\/wp-json\/wp\/v2\/posts\/1412\/revisions\/1641"}],"wp:attachment":[{"href":"https:\/\/www.itforce.mn\/index.php\/wp-json\/wp\/v2\/media?parent=1412"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.itforce.mn\/index.php\/wp-json\/wp\/v2\/categories?post=1412"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.itforce.mn\/index.php\/wp-json\/wp\/v2\/tags?post=1412"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}