WSUS: Viewing Updates with PowerShell

In my previous post, I showed you how to make a connection to a WSUS server, view clients reporting to the server and how to start and view the progress of a WSUS sync. In this post, I will show you how to view all of the updates on the server and look at the details of the updates.

Using the already made $wsus variable, you can take advantage of the GetUpdates() method to list out every single update that is available on the WSUS server to either approve or decline.

$wsus.GetUpdates()

Untitled

You can get a lot of detailed information about each update such as the creation date, arrival date, kb article, installation/uninstallation behavior.

Listing the Installation Behavior of a patch:

$update = $wsus.GetUpdates() | Select -first 1
$update.InstallationBehavior

Untitled

Listing the Uninstallation Behavior of a patch:

$update = $wsus.GetUpdates() | Select -first 1
$update.UninstallationBehavior

Untitled

You can even generate a report of updates that have been approved using the IsApproved property.

Approved Patches:

$wsus.GetUpdates() | ? {$_.IsApproved -eq "True"} | Select Title,ProductTitles, KnowledgebaseArticles,`
SecurityBulletins, CreationDate, ArrivalDate

Untitled

Likewise, you can use the IsDeclined property to report all patches that have been declined.

$wsus.GetUpdates() | ? {$_.IsDeclined -eq "True"} | Select Title,ProductTitles, KnowledgebaseArticles,`
SecurityBulletins, CreationDate, ArrivalDate

This snippet will report all patches that have been released in the past month:

$wsusserver = "wsusserver"
[void][reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration")
$wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer($wsusserver,$False)
$wsus.GetUpdates() | ? {$_.CreationDate -gt (Get-Date).addMonths(-1)} | Select Title,ProductTitles,`
KnowledgebaseArticles, SecurityBulletins, CreationDate, ArrivalDate

Untitled

On a side note, if you ever wanted to know the descriptions for the various classifications for each update, such as Drivers, Critical Updates, Service Packs, etc… You can use this snippet to get the definitions:

$wsusserver = "wsusserver"
[void][reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration")
$wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer($wsusserver,$False)
$wsus.GetUpdateClassifications() | FT Title, Description -wrap -auto

Untitled

Not really earth-shattering, but still something interesting.

This entry was posted in powershell, WSUS and tagged , , . Bookmark the permalink.

6 Responses to WSUS: Viewing Updates with PowerShell

  1. Marcio says:

    Hello, this awsome, but there as also list the release date, item and size?

  2. pjuster says:

    really great advice on this page, one typo
    Listing the Uninstallation Behavior of a patch:
    $update = $wsus.GetUpdates() | Select -first 1
    $update.InstallationBehavior

    should be
    $update = $wsus.GetUpdates() | Select -first 1
    $update.unInstallationBehavior

  3. Chris Brown says:

    I’ve been waiting for something like this for a very long time! Thank you so much for this awesome Module. Will save me a lot of time and, more importantly, a lot of SQL scripts!

  4. Michael Bradley says:

    Great series. Thank you for the post.

  5. Pingback: Tweets that mention WSUS: Viewing Updates with PowerShell | Learn Powershell | Achieve More -- Topsy.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s