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:
Get-VMHost | ForEach-Object -Process {
[PSCustomObject]@{
'lastpatchdate' = [datetime]((Get-ESXCli -VMHost $_).software.vib.list() |
Select-Object -Property installdate -ExpandProperty installdate |
Sort-Object -Descending)[0]
'host' = $_.Name
'version' = $_.version
'build' = $_.build
}
}
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.
Get-Inventory -Name MyHost | Scan-Inventory