Categories

Windows Updates: 1 Discovering Updates

I want to spend a few posts looking at Windows updates. There is a COM object model that enables us to work with the updates system.

Any update processing starts with discovering the updates that are available

001
002
003
004
005
006
007
008

function get-update {
$session = New-Object -ComObject Microsoft.Update.Session
$searcher = $session.CreateUpdateSearcher()

$result = $searcher.Search("IsInstalled=0 and Type='Software'" )

$result.Updates | select Title, IsHidden
}

 

Create an object representing an update session

Create an update searcher and search for software updates that aren’t installed.

We can then output the update title and if its hidden or not.  Other properties are available.

One Response to Windows Updates: 1 Discovering Updates

  • GiZmO says:

    If you replace the line:
    $session = New-Object -ComObject Microsoft.Update.Session

    And instead place these two lines:
    param($ComputerName=$env:COMPUTERNAME)
    $Session = [Activator]::CreateInstance([Type]::GetTypeFromProgID(“Microsoft.Update.Session”,$ComputerName))

    You’ll be able to get status for remote machines as well.

Leave a Reply