Recently I got asked to create an overview for a license audit we were receiving. Nothing all to difficult is what I thought at first. But then I had a look at the requirements and they were asking for the ESXi install date for each host.

Well when you have a couple hundred hosts in your environment, you do not want to login to each host and run a command. There is even a difference in commands that can be used when you have different versions of ESXi hosts in your environment, which makes it even more tedious. The below commands are examples that can be used to find your ESXi install date, all of these can be run on the ESXi shell:

ESXi 5.x and 6.0 hosts:

ESXi 5.x – 6.0 command

ESXi 6.5 hosts:

ESXi 6.5 command

Fortunately, since vSphere 6.5 there is a new API call that can be used to fetch the ESXi install date, so that you can instead do this scripted on each ESXi host. I actually tried to do this with the Putty Plink functionality but I failed, I couldn’t get it to work. It somehow couldn’t escape some characters that are needed to get the result.  

But I did get to make a script that does the trick with PowerCLI and uses both of the commands above and gives me all the data that is needed for mixed environments with ESXi 6.0 and ESXi 6.5. If you want to use this script you should edit the Clusternames and the Export-CSV file locations.

The only thing that is missing here is the fact that I’m also getting the object name for the ESXi 6.0 result, but I can live with that. I couldn’t fix that in the time that I had.

Script “hostinfototal.csv” preview

The script uses a vSphere Clustername as input and then creates an overview for each cluster in three different comma separated files (csv’s). Unfortunately the “Export-CSV” cmdlet doesn’t let me merge these overviews in one excel file with multiple sheets, so this was the quickest way around that issue. The script uses ESXCLI embedded into PowerCLI for the ESXi 6.0 hosts and uses the new ESXi 6.5 API call for those hosts.

There you have it! A script that helps you create some overviews that are needed for certain licensing audits.

Want to know more PowerCLI tips and tricks? Click on the button below:

Leave a Reply

Your email address will not be published. Required fields are marked *