Use PowerShell to list and export all updates from a Windows machine

Sometimes when trying to find particular updates and troubleshoot Windows update problems you need to be able to manipulate the update data.  Using the ‘installed updates’ applet is not always practical.  I use the below script to give me a .csv files with all updates installed on a machine.

$Session = New-Object -ComObject "Microsoft.Update.Session"
$Searcher = $Session.CreateUpdateSearcher()
$historyCount = $Searcher.GetTotalHistoryCount();$Searcher.QueryHistory(0, $historyCount) | Select-Object Date,@{name="Operation"
expression={switch($_.operation){1 {"Installation"}; 2 {"Uninstallation"}; 3 {"Other"}}}}, @{name="Status"
expression={switch($_.resultcode){1 {"In Progress"}; 2 {"Succeeded"}; 3 {"Succeeded With Errors"};4 {"Failed"}; 5 {"Aborted"} }}}, Title, Description | Export-Csv "c:\temp\WindowsUpdates.csv" -NoTypeInformation 

Leave a Reply

Your email address will not be published. Required fields are marked *