Show Windows Updates Locally With PowerShell

I wanted to be able to quickly show the Windows Updates on a server. This came about during a discussion about auditing.

Of course, there is no point in re-inventing the wheel so I had a quick Google and  found a couple of posts on from  Hey Scripting Guy blog and one from Tim Minter. Neither quite did what I wanted so I modified them as follows.

We start by creating a Update object and find the total number of updates and setting them to a variable $History which we pass to the QueryHistory Method. This enables us to show all the updates


Passing this to Get-Member shows


which doesn’t show the KB so I read a bit more and found Tom Arbuthnot’s Blog Post


this transforms the ResultCode Property to something meaningful and places the KB in its own column.

I have created a function called Show-WindowsUpdatesLocal It’s Local because doing it for a remote server takes a different approach but I will show that another day.

This means you can call the function and use the results however you like



Show-WindowsUpdatesLocal| Select Date, HotfixID, Result|Format-Table -AutoSize


Show-WindowsUpdatesLocal|Where-Object {$_.Result -eq ‘Failed’} |Select Date, HotfixID, Result,Title|Format-Table -AutoSize


Output to file Show-WindowsUpdatesLocal|Format-Table -AutoSize|Out-File c:\temp\updates.txt


Output to CSV Show-WindowsUpdatesLocal|Export-Csv c:\temp\updates.csv


You can get the code here Show-WindowsUpdatesLocal


One thought on “Show Windows Updates Locally With PowerShell

  1. Pingback: (SFTW) SQL Server Links 04/10/13 • John Sansom

Leave a Reply

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

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

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s