Exporting ESX/ESXi Host Information to Excel

hostinfoFor those of us who do not jump around from environment to environment often forget how lucky we are to know the details of our servers intimately. Over time you come to know what to expect and when something is just not right.

What if someone were to hand you a list of VMware hosts….with little to no documentation? This can be a bit daunting for sure.  There are literally hundreds of details to look at from host setup, to networking, to storage and everything in between.

Recently, this happened to me and it got me thinking about ways to document such ‘new-to-me’ hosts.  As an added bonus, not all VMware hosts (for whatever the reason) are tied to a vCenter server.  Opening up multiple vSphere clients individually wasn’t the plan for me – I decided to write a PowerCLI script that would do the heavy lifting for me.  The idea, was to gather as much info as possible and export the data to an Excel workbook.

I’ve seen a few Export-Xlsx functions floating around but had not gotten the chance to take a look and see what they could do and how easily they could accomplish the task. These functions give you the ability to create workbooks with multiple sheets – much more robust than Export-CSV.  I finally settled on a function written by LucD and Gilbert van Griensven. It seems to work really well and I plan to add this functionality to reporting type scripts in the future. To keep everything nice and in a single file, I added the Export-Xlsx function to the script itself as opposed to calling from a module or something similar.

Running the script is pretty basic.  There are only two parameters – server and path. The server parameter is used to feed the script one or more VMware host names (Not vCenters(!)) while the path parameter defines a folder to save the output to. Once run, you will be prompt for the host credentials (they must be the same for all servers in a single run).

I’ve tried my best to test the script on ESX (4) and ESXi hosts (4.1 – 5.5) using the latest version of PowerCLI (5.8 R1). While the script is not exactly optimized with all the fancy Get-View commands, I don’t expect to run it often.  In my testing, it takes anywhere from 2 to 5 mins per host to complete.  PowerShell v3 and Excel are required on the script host for the script to run.

I tried to grab any and all info I could find browsing the available cmdlets – if you feel something is missing, please let me know and I’ll see if it can be incorporated.

The following is a list of data exported:

  • General Host Info
  • HBA Info
  • Disks
  • SCSI LUNs
  • Multipath Info
  • iSCSI Targets
  • Diagnostic Partition Info
  • Datastores
  • Datastore Chart (Used vs Free)
  • Physical NIC Info
  • VMKernel Info
  • Service Console Info
  • Standard Switch Info
  • Standard Port Group Info
  • Distributed Switch Info (Limited)
  • Distributed Port Group Info (Limited)
  • Firewall Exceptions
  • Services Info
  • SNMP Info
  • Installed Patches
  • Local Users/Groups
  • VI Roles
  • Permissions
  • VM Info
  • Snapshot Info

 

 

Advertisements

3 thoughts on “Exporting ESX/ESXi Host Information to Excel

  1. Little Jim

    If anybody runs into an error that goes;

    + #Requires â?”Version 3
    + ~~~~~~~~~~
    The string is missing the terminator: “.
    At .\Get-VMHostInfo.ps1:1 char:11
    + #Requires â?”Version 3
    + ~~~~~~~~~~~~

    It’s because your editor is using an HTML “-“symbol (&ndash) instead of what you were expecting. Type another dash next to it and see the tiny little difference: – –

    Reply

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s