Dec 272018
 December 27, 2018  Posted by at 1:50 pm PowerShell  Add comments

Merry Christmas! I hope you’ve had a lovely Christmas holiday, with food, love and fun! We spent a laid back Christmas with my best friend Jonas and his fiance, and with then two weeks old Loke Tiberiu. We had planned to travel to Norway, but with my due date being right before Christmas we planned the celebration in Sweden instead- just the five of us to avoid getting Loke sick.

A few months back I was writing about Windows Updates as I came across some problems while manually running the updates on our machines at work. I wrote a tiny script to check for pending updates (excluding anything related to Silverlight updates) that we can run on all our machines to generate a quick report. It’s a temporary solution until we tweak our monitoring and management tools.

Anyways, here is the script:

$msUpdateSession = [activator]::CreateInstance([type]::GetTypeFromProgID("Microsoft.Update.Session",$env:COMPUTERNAME))
$updates = $msUpdateSession.CreateUpdateSearcher().Search("IsInstalled=0").Updates

$silverLightInstalled = Get-WindowsFeature | where { $_.Name.ToLower() -like 'silverlight' }

$pendingUpdates = [System.Collections.ArrayList]@()

$updates | % {

$title = $_.Title

if ($_.Title.ToLower().Contains("silverlight")){


$updatesCount = $pendingUpdates.Count

if($updatesCount -gt 0){
    Write-Host "***** $updatesCount updates pending for Iris Awesome COmputer*****" -BackgroundColor Black -ForegroundColor Yellow
    $pendingUpdates | % { Write-Host $_}

    Write-Host "***** No pending updates for $env:COMPUTERNAME*****" -BackgroundColor Black -ForegroundColor Green

Result (updates are now installed 😉 )
windows updates PoSh

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>



What is 15 + 11 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)