Another way to check Update Installed via Powershell

I have to check if machine has MS March update installed, and SCCM cannot make my job simpler 🙁

So I created a new compliance rule to check the result, here is the code:


try {

$Session = New-Object -ComObject “Microsoft.Update.Session”

$Searcher = $Session.CreateUpdateSearcher()

$historyCount = $Searcher.GetTotalHistoryCount()

$Searcher.QueryHistory(0, $historyCount) | Select-Object Title, Description, Date,

    @{name=“Operation”; expression={switch($_.operation){

        1 {“Installation”}; 2 {“Uninstallation”}; 3 {“Other”}



catch { “March, 2017 Security Monthly Quality Rollup” }

if (!$error) {

Write-Host “Compliant”


else {Write-Host “Non-Compliant”}


Leave a Comment