PowerShell script to gather ESXi host details

I came across a situation where I had to quickly gather details of all ESXi host hardware details. For small environment this can be obtained via VIClient UI but if the environment is large it makes lot of sense to have some script ready to serve this purpose for you. After some hit-n-trials finally the script was ready to capture these details and the entire process of collecting around 300 host details was so fast that the output was ready and stored in a nice .csv format within minute.

So here is the script and required pre-requisites to run it

  1. Server from where this script is run should have Powershell & PowerCLI (modules) installed on it
  2. However the script should call for VMware snapins to run itself but incase it fails to do so please add “VMware.VimAutomation.Core” snapin manually into Powershell
  3. The server from where you are running this script shall talk to vCenter server on Port 443
  4. Replace the BOLD values with desired vCenter server details & credentials
Please note that the script is of 6 lines, remove the line text and then run the script
line1: Connect-VIServer -Server server_fqdn -User username -Password passwd
line2: Add-PSSnapin VMware.VimAutomation.Core -ErrorAction 'SilentlyContinue'
line3: Clear-Host
line4: $esxi = Get-VMHost | Sort Name
line5: $D = $esxi | Select-object @{N="HostName";E={ $_ | Get-VMHostNetwork | select -ExpandProperty Hostname}},Manufacturer,Model,ProcessorType,NumCpu,MemoryTotalGB,Version,Build
line6: $D | Export-Csv -Path "path_name\file_name.csv"

With this I end this blog…. I hope it helps… .till then Happy Reading.. 🙂


5 thoughts on “PowerShell script to gather ESXi host details

Add yours

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a free website or blog at WordPress.com.

Up ↑

%d bloggers like this: