This page looks best with JavaScript enabled

PowerCLI last patch date script to get VIB install date

 ·  ☕ 1 min read  ·  ✍️ Javy de Koning

PowerCLI last patch date

You might find yourself wanting a report of when your vSphere servers have been patched for the last time. Here you will find a simple PowerCLI script that uses vSphere CLI to query the last VIB install date.

PowerCLI script:

 1Get-VMHost | ForEach-Object -Process { 
 2  [PSCustomObject]@{
 3    'lastpatchdate' = [datetime]((Get-ESXCli -VMHost $_).software.vib.list() |
 4      Select-Object -Property installdate -ExpandProperty installdate |
 5      Sort-Object -Descending)[0]
 6    'host'        = $_.Name
 7    'version'     = $_.version
 8    'build'       = $_.build
 9  } 
10}

You should still rely on vSpere Update Manager

There you have it. A really simple and effective way to report on last patch date. However, keep in mind that the last VIB install date does not necessary say the system was fully patched on that date. Use vSphere update manager to scan for any missing (critical) patches. As of vCenter 6.5 the VMware vSphere Update Manager is embedded into the vCenter Server Appliance! Another reason to leave your Windows vCenter environment behind. As of the next major version vCenter will no longer be released for Microsoft Windows.

To scan your host using the VUM PowerCLI cmdlets you can use the following one-liner.

1Get-Inventory -Name MyHost | Scan-Inventory

Javy de Koning
WRITTEN BY
Javy de Koning
Geek 🤓, Love sports 🏃‍♂️🏋️‍♂️, Food 🍛, Tech 💻, @Amsterdam ❌❌❌.