Find ESXi Installation Date with PowerCLI

I recently noticed a link to a very interesting article on Twitter: Find ESXi Installation Date — http://vcdx56.com/2016/01/05/find-esxi-installation-date/. These steps are straight forward and show how to calculate the original ESXi install date, looking at the first section of the UUID. I didn’t realize so much useful information was coded into the UUID, but this could be useful information for certain reports. To understand the process, please check out the original article on vcdx56.com.

The following few lines of code will return this information for all hosts in a vCenter using PowerCLI.

# Find ESXi install date: http://vcdx56.com/2016/01/05/find-esxi-installation-date/
# Convert HEX to DEC: http://michaelflanakin.com/Weblog/tabid/142/articleType/ArticleView/articleId/1073/Converting-ToFrom-Hex-with-PowerShell.aspx
# Convert epoch to date: http://stackoverflow.com/questions/10781697/convert-unix-time-with-powershell

Get-VMHost | Sort Name | %{
  $thisUUID = (Get-EsxCli -VMHost $_.name).system.uuid.get()
  $decDate = [Convert]::ToInt32($thisUUID.Split("-")[0], 16)
  $installDate = [timezone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddSeconds($decDate))
  [pscustomobject][ordered]@{
    Name="$($_.name)"
    InstallDate=$installDate
  } # end custom object
} # end host loop

One Comment

Leave a Reply

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

*

Notify me of followup comments via e-mail. You can also subscribe without commenting.