PowerShell – Windows Update report to .CSV

A while back I was asked by my boss to come up with a way to get a report of all the Windows Updates installed on a remote server that is at a client’s site and that we do not have access to.

I thought to myself that he must be crazy to think that we could even find a utility that would enable us to do that.

Well….. Apparently with the right Power Shell Commands you can do it. Here is the Syntax for the Script that you will need to save as a .ps1

$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 | Export-Csv -NoType “$Env:userprofileDesktopWindows Updates.csv”

The result looks something like this:

I hope you find this post helpful and are able to use this going forward.

Windows Update cannot currently check for updates because the service is not running

I recently ran into an issue where a client of mine had a issue with Windows Update failing to run. It gave the end user a pop up error message that looks like this:

Once you click okay you will then see this on the Window’s Update screen. Clicking Check for updates will result in the same message. 
I did some googling and found that if I Stop the Windows Update service and then delete or rename C:WindowsSoftwareDistribution and then restart the service you would then be able to run Windows update. However this did not work. 
I then found a Microsoft Support KB article KB3102810 which will allow you to download an update which will resolve the issue. After the update is installed you will need to stop the Windows Update Service again, delete or rename the Software Distribution folder and restart the machine. Once it comes back up you can then click Check for Update and after about an hour (because it now has to rebuild it’s update catalog)  you will get a similar screen to what you will see below. 
Hope you find this helpful with your Windows update issues.