Shawn Masterson's Blog

Exporting ESX/ESXi Host Information to Excel

For 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:

 

 

Exit mobile version