Friday, March 25, 2022

Get Number of Days since last Windows Udpate was applied

In order to pre-emptively identify computers that are not getting software updates you might want to know how long it has been since they last applied a Windows Update.  Here you go:

$TimeNow = Get-Date
$LastSUInstall = ((Get-WmiObject -Class win32_quickfixengineering -Namespace root\cimv2).InstalledOn | sort -Descending)[0]
[Int]$OutputInt = ($TimeNow.Subtract($LastSUInstall)).Days
Write-Output $OutputInt