In the following code block for the last windows update time, please add a check for BatchPatch as an ApplicationID. We have several Server Core machines that are only updated this way, it doesn't show a last update date.
$searcher = (New-Object -ComObject Microsoft.Update.Session).CreateUpdateSearcher();
$count = $searcher.GetTotalHistoryCount();
$result = 0;
if ($count -gt 0) {
$index = 0;
$maxindex = 100;
if ($count -le 100) {
$maxindex = $count;
}
$history = $searcher.QueryHistory($index, $maxindex);
foreach ($item in $history) {
$clappid = $item.ClientApplicationID
if ($clappid -eq 'CcmExec' -or # SCCM Updater
$clappid -eq 'UpdateOrchestrator' -or # Windows 10+ Updater
$clappid -eq 'AutomaticUpdates' -or # before Windows 10 Updater
$clappid -eq 'AutomaticUpdatesWuApp' # WSUS Updater
) {
if ($item.ResultCode -eq 2) { # 2 = orcSucceeded
$result = $([int64]$($((get-date).ToUniversalTime()) - ($searcher.QueryHistory($index, 1) | Select-Object Date).Date).TotalSeconds);
break;
}
}
$index++;
}
if ($result -eq 0) {
$result = -3; # the last 100 entries didn't contain a successfull windows update
}
} else {
$result = -2; # the history entry collection is empty
}
$result
Windows Update Sensor to include BatchPatch
Votes:
0
5 Replies
Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.
Add comment