WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud Foundation
  • VKS
  • Homelab
    • Resources
    • Nested Virtualization
  • VMware Nostalgia
  • Apple

Super easy way of getting ESXi installation date in vSphere 6.5

10.30.2016 by William Lam // 2 Comments

Sometimes it is the small updates which improves an existing feature or enhances the current user experience that I most appreciate with a new vSphere release. One area that I recently came across while working with vSphere 6.5 is just how easy it is now to retrieve the ESXi installation date which can be useful for troubleshooting or auditing purposes. This previously required you to decode the ESXi UUID which was needed to construct the originally installation date as outlined in this VMware KB 2144905 article.

With ESXi 6.5, you can now quickly retrieve the ESXi installation date simply by using this new ESXCLI command:

esxcli system stats installtime get

esxcli-6-5-installation-date-2
Note: ESXCLI can be executed either locally within the ESXi Shell or remotely using vCLI or PowerCLI.

In case that was not enough, the Engineer who added this capability was also kind enough to add a native vSphere API to also retrieve the ESXi installation date from a programmatic approach. Under the existing ImageHostConfigManager there is now a new vSphere 6.5 API called installDate() which returns the installation date in UTC format.

To demonstrate this new vSphere API, I have created a small PowerCLI function called Get-ESXInstallDate which can be downloaded from here.

Here is an example of retrieving the installation date for a specific ESXi host:

esxcli-6-5-installation-date-1

Categories // Automation, ESXi, vSphere 6.5 Tags // esxcli, ESXi 6.5, PowerCLI, vSphere 6.5, vSphere API

How to tell if an ESXi host is a VSAN Witness Virtual Appliance programmatically?

09.26.2016 by William Lam // Leave a Comment

I had received this question awhile back but I was only able to get to it recently. If you are not familiar with the VSAN Witness Virtual Appliance and its purpose, Cormac Hogan did an excellent write-up on the topic which you can find it here.

how-to-tell-if-esxi-is-vsan-witness-vm-0
The reason this question came up was that if you were to simply iterate over all ESXi hosts within your vSphere Inventory from an Automation standpoint, you might find a mix of regular ESXi hosts and potentially this new VSAN Witness Virtual Appliance which is basically an ESXi host that runs in a VM (e.g. Nested ESXi). Although, it may look and feel like a regular ESXi host, it is not and the question was how might you go about distinguishing between the two? You can of course setup specific naming standards, folder structure or separate datacenter objects, but you still may accidentally retrieve a VSAN Witness host without even realizing it.

One quick solution is to check for a specific ESXi Advanced Setting called Misc.vsanWitnessVirtualAppliance which will return a value of 1 if it is the VSAN Witness Appliance. Here is a quick PowerCLI snippet which demonstrates how you can access this property:

$vmhost = Get-VMHost -Name 192.168.1.115
Get-AdvancedSetting -Entity $vmhost -Name Misc.vsanWitnessVirtualAppliance

how-to-tell-if-esxi-is-vsan-witness-vm-1
Although the method described above is one quick way to easily identify whether an ESXi host is a VSAN Witness Appliance, it is also limited in the information that it provides you. Another approach is to actually use the new VSAN 6.2 Management API and specifically the Stretched Clustering System APIs to retrieve the associated VSAN Witness host for a given VSAN Cluster. Not only will you get more information about the specific ESXi host providing the VSAN Witness functionality which will allow you to correlate back to your vSphere Inventory, but you will also get additional VSAN Witness configuration such as the preferred Fault Domain, Node UUID and the VSAN Cluster that it is associated with for example.

Here is a quick VSAN Management SDK for Python sample script that I had created called vsan-stretched-cluster-system-sample.py which implements the VSANVcGetWitnessHosts() API method. The script prints out a few of the WitnessHostInfo properties as shown in the screenshot below.

how-to-tell-if-esxi-is-vsan-witness-vm-2
One other option is if you simply just want to know if a given ESXI host is a VSAN Witness host or not, there is also the VSANVcIsWitnessHost() API that simply returns a boolean value. This might useful if you just have a list of ESXi hosts retrieved through the vSphere API and no knowledge of the underlying VSAN Clusters.

Categories // Automation, ESXi, PowerCLI, VSAN Tags // Misc.vsanWitnessVirtualAppliance, PowerCLI, Virtual SAN, VSAN, vSphere API, witness

Quick Tip - How to retrieve the ESXi Update Level using the vSphere API?

08.17.2016 by William Lam // Leave a Comment

Using the vSphere API, it is very easy to extract the version and build of all your ESXi hosts. This information is exposed in the Product property of an ESXi host. For example, Product.Version will return something like 6.0.0 and Product.Build will return something like 3029758. However, one thing that is not available in this property is the Update Level information for an ESXi host such as Update 1 or Update 2.

Historically, customers would have to rely on ESXCLI to pull the Update level information using the following command: esxcli system version get and though this can be run remotely or integrated into PowerCLI as shown in the example below, it would be ideal if this information was just available using the vSphere API.


$esxcli = Get-EsxCli
### To retrieve Major/Update version number of ESXi via ESXCLI
PS C:\Users\lamw\Desktop> $esxcli.system.version.get().version + " Update" + $esxcli.system.version.get().update
6.0.0 Update1
### To retrieve all version information from ESXi via ESXCLI
PS C:\Users\lamw\Desktop> $esxcli.system.version.get()
Build : Releasebuild-3029758
Patch : 17
Product : VMware ESXi
Update : 1
Version : 6.0.0

view raw

gistfile1.txt

hosted with ❤ by GitHub

This exact same question was brought up internally again today and Etienne Le Sueur actually shared an awesome tidbit on how to retrieve this information using the vSphere API. You can find the ESXi Update Level information in an ESXi Advanced Setting called Misc.HostAgentUpdateLevel

Below is a quick PowerCLI example which exercises this vSphere API to retrieve the Version, Build and Update Level information:

$vmhost = Get-VMHost -Name nuc.primp-industries.com

$esxi_version = $vmhost.ExtensionData.Config.Product.Version
$esxi_build = $vmhost.ExtensionData.Config.Product.Build
$esxi_update_level = (Get-AdvancedSetting -Entity $vmhost -Name Misc.HostAgentUpdateLevel).value

Write-Host "$vmhost" 
Write-Host "`tVersion: $esxi_version"
Write-Host "`tUpdate: $esxi_update_level"
Write-Host "`tBuild: $esxi_build"

Here is a screenshot of the output for my ESXi host which is running latest vSphere 6.0 Update 2 (including the recent patch release).

retrieve-esxi-update-level-using-vsphere-api

Its great to hear that the ESXi Update Level information is available through the vSphere API, although I would have liked to have seen it exposed within the Product property. Perhaps its time to file an internal Feature Request? 🙂

Categories // Automation, ESXi, PowerCLI Tags // build, ESXi, Misc.HostAgentUpdateLevel, PowerCLI, update, version, vSphere API

  • « Previous Page
  • 1
  • …
  • 9
  • 10
  • 11
  • 12
  • 13
  • …
  • 29
  • Next Page »

Search

Thank Author

Author

William is Distinguished Platform Engineering Architect in the VMware Cloud Foundation (VCF) Division at Broadcom. His primary focus is helping customers and partners build, run and operate a modern Private Cloud using the VMware Cloud Foundation (VCF) platform.

Connect

  • Bluesky
  • Email
  • GitHub
  • LinkedIn
  • Mastodon
  • Reddit
  • RSS
  • Twitter
  • Vimeo

Recent

  • Programmatically accessing the Broadcom Compatibility Guide (BCG) 05/06/2025
  • Quick Tip - Validating Broadcom Download Token  05/01/2025
  • Supported chipsets for the USB Network Native Driver for ESXi Fling 04/23/2025
  • vCenter Identity Federation with Authelia 04/16/2025
  • vCenter Server Identity Federation with Kanidm 04/10/2025

Advertisment

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2025

 

Loading Comments...