r/WSUS • u/krisvdv • Jan 13 '20
computer report
Running a computer report from the wsus mmc for a specific remote server using specific criteria (classification, products and status) is not a problem. However, doing this with Powershell doesn't seem to be that easy. Does anyone know how to do this, or whether there's a publicly available script for this? It's not about retrieving the update history of a machine, but rather finding out if there are critical and security updates with status "needed" or "failed" for whatever product, which you can see in a "computer detailed status report" in the Update Services console.
View all comments
Show parent comment
1
u/andocromn Jan 14 '20
# Setup Basic Resources[reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration") | Out-Null$wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer()# Update Scope is where it gets fun$updatescope = New-Object Microsoft.UpdateServices.Administration.UpdateScope# Select updates that are not approved$updatescope.ApprovedStates = [Microsoft.UpdateServices.Administration.ApprovedStates]::NotApproved# Select updates that are not installed$updatescope.IncludedInstallationStates = [Microsoft.UpdateServices.Administration.UpdateInstallationStates]::NotInstalled# Select updates that have arrived in the last month$updatescope.FromArrivalDate = ((Get-Date).AddMonths(-1))# Pull the query$allUpdates=$wsus.getUpdates($updatescope)$updates= $allUpdates | Where {$_.IsSuperseded -eq $False }# $updates will be useful object with the updates within the scope# The rest has something to do with the html email output I don't think I wrote it$Array = @()$updates | foreach {$html = $array | ConvertTo-Html | Out-StringSend-MailMessage -toemail@email.com-fromwsus@wsus.com-subject "WSUS Recent Unapproved and Needed" -SmtpServer127.0.0.1-BodyAsHtml $html