ESXi Host Versions – PowerCli

Okay, so I would admit that I’m not the best with PowerCli but recently we had a request to produce a list of all of the ESXi hosts we have on a vCenter along with their Version and build number.

Now this can be done easily on an individual basis by logging onto each host and running the command:

vmware -vl

This will produce a result similar to below:



Unfortunately performing this command on a number of hosts could be time consuming.  I therefore went ahead and produced the following PowerCli script that would collect it for a number of hosts on a vCenter… as previously explained, there may be a better way to perform this in PowerCli but this solution worked for me:

Connect-VIServer -Server vCenterName

$style = "<style>BODY{font-family: Arial; font-size: 10pt;}"
$style = $style + "TABLE{border: 1px solid black; border-collapse: collapse;}"
$style = $style + "TH{border: 1px solid black; background: #dddddd; padding: 5px; }"
$style = $style + "TD{border: 1px solid black; padding: 5px; }"
$style = $style + "</style>"

$smtpServer = "smtpservername"
$smtpFrom = "VMware Build Versions <senderemailaddress>"
$smtpTo = "destinationemailaddress"
$messageSubject = "VMware Build Versions - $(Get-Date)"
$message = New-Object System.Net.Mail.MailMessage $smtpfrom, $smtpto
$message.Subject = $messageSubject
$message.IsBodyHTML = $true 

$dts = @(
get-view -ViewType HostSystem -Property Name, Config.Product | select Name,@{ expression={$_.Config.Product.Version}; label='Version' },@{ expression={$_.Config.Product.Build}; label='Build Number' }
$message.Body = $dts | ConvertTo-HTML -Head $style

$smtp = New-Object Net.Mail.SmtpClient($smtpServer)

This should produce an email with a table similar to below:

About the Author


I have been in IT for the past 15 years and using virtualisation technologies for around the past 8 years. I started, as quite a lot of people do, working with PCs after playing with such iconic systems like the ZX81, ZX Spectrum and then progressing through 386s, 486s, Pentiums etc. After being headhunted at sixth form to work for a small company based around Hertfordshire, UK. I began working with small businesses and gaining a lot of hardware experience. Three years later, after helping to increase the size of the business, I needed to gain exposure to a larger environment to progress my own career. I joined a large manufacturing company around Electronic Test and Measurement which progressed my skills onto more PC work, hardware work and then onto Server Operating Systems. I progressed again onto a consultancy company based in Reading, UK. Initially working as an engineer performing hardware / software installations for larger companies contracted out to the consultancy company, I moved up into a Consultant position continuing my travel across the UK assisting and providing solutions to companies. I finally moved on again to my current position, working back in Hertfordshire, UK. Again working for a large manufacturing company, this time with over 50,000 users worldwide. I am responsible for the datacenter hardware, the storage environment, the vmware environment and also implementing their new Citrix XenApp farm. My days are busy but also productive, its a friendly environment and in my four years of being with the company, I have seen many changes in technology and infrastructure in use within the company. About the site I started this site as I had been thinking of having more of a presence on the web for a while. On a daily basis, I perform tasks and use tools that others may not use or may not think to do and therefore I thought that I would share some of these experiences and tips with others to help with their day to day work. Currently, my main focus of work is around VMware and Veeam Backup & Replication but hopefully as my tasks progress, I’ll be able to share useful bits of information about other areas of IT as well.

Leave a Reply

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