Last week there was a question that was posted internally asking if it was possible to customize the ESXi DCUI screen to include the number of Virtual Machines? Although there is nothing out of the box, you can in fact add add almost anything to the DCUI screen by modifying the /etc/vmware/welcome configuration file which I had blogged about several years back on adding a splash of color to the ESXi DCUI. There was even a recent VMware Fling that provides a VIB that applies a variety of DoD STIG implementations, one of which was to update the DCUI screen with some specific text.
However, instead of having to manually edit the file directly on the ESXi host, we also provide an API in the way of an ESXi Advanced Setting called Annotations.WelcomeMessage which can then be updated remotely using anyone of the vSphere SDK/CLIs that you are familiar with.
Here is an example PowerCLI snippet to connect to an ESXi host (you can also do this by connecting to vCenter Server) and extracting all Virtual Machines residing on the host and then updating the DCUI screen with the total number of VMs as well as the names of each VM. Obviously, if you have more than 10 or so VMs, it may not make much sense to actually list them as it will just run off the screen, but this just gives you an example of some of the things you can do leveraging the vSphere API or any other data that you might have at your disposal.
Connect-VIServer -Server 192.168.1.50 -User root -Password vmware123 $vms = Get-View -ViewType VirtualMachine -Property Name $DCUIString = "{color:yellow} {esxproduct} {esxversion} Hostname: {hostname} IP: {ip} Virtual Machines: " + $vms.Count + " {/color} {color:white} " foreach ($vm in $vms) { $DCUIString += "`t`t" + $vm.Name + "`n" } Set-VMHostAdvancedConfiguration -Name Annotations.WelcomeMessage -Value $DCUIString Disconnect-VIServer -Confirm:$false
Note: If you wish to only filter out powered on Virtual Machines, you can add the following: -Filter @{"Runtime.PowerState" = "PoweredOn"} to the end of the Get-View command
Here is a screenshot quick screenshot of what this would look like on the DCUI screen of your ESXi host:
Note: You can actually run the DCUI over SSH, which can be useful for testing purposes without having to directly login to the console remotely. Take a look at this blog post here for more details.
One final thing to be aware of when editing the welcome message on your ESXi host is that it will also be displayed in the ESXi Embedded Host Client login page as shown in the screenshot below. Just something to be aware of in case you plan to make any sensitive information available as this can be seen without needing to login to the ESXi host (just like the DCUI interface).
This will really help us to search vcenter server incase we loss connectivity
The comment above beat me to it, is it possible to create a filter that only shows a specific VM, as mentioned previously vcenter?
Yes, anything is possible 🙂
This is just a simple -filter option: $vms = Get-View -ViewType VirtualMachine -Property Name -Filter @{"Name" = "VCSA-60u2"}
If you're not familiar with PowerCLI, I recommend you have a look at their documentation https://www.vmware.com/support/developer/PowerCLI/ and there's plenty of examples online that you can search for as well
Is this setting a static message with the count and VM names at the time of execution, or will the list update dynamically?
I'm guessing the former, but very cool in either case! I didn't know the DCUI was so easily modifiable. Thanks!
It's static, but easily scheduledable
Hey there Lam! Fantastic tip! You really rocks! Thanks a lot for sharing.
Cheers!
Valdecir - São Paulo, Brazil
In 6.7 esx version ,hostname and IP I get null values, must be differnet....