$ExitCode = 0 $Threshold = -30 $RefDate = (Get-Date).AddDays($Threshold) $LastUpdate = ((get-hotfix | sort installedon)[-1]) $LastUpdateDate = $LastUpdate.Installedon if ($LastUpdateDate -lt $RefDate) {$ExitCode = 1001} Write-host $LastUpdate.HotfixID $LastUpdate.Description $LastUpdateDate.ToShortDateString() "Exitcode =" $ExitCode Exit $ExitCode