PowerShell

Getting Last Installation Success Date and Last Search Success date of Windows Updates using Powershell.

 

Everyday is a new day , with new problems and new issues, sometime at users side and sometime at Server side. The life in IT is quite happening.

These new issues and problems leads to new solutions and new scripts.

In my environment I asked few users to run their windows updates, but as you know user never listen ;o), So i thought to find out which users had install and run windows update and which is not.

The first thing which come in my mind is to check any com object available to windows update.

Luckily i found a “Microsoft.Update.AutoUpdate” com object and i thought lets give it a try.

I create a new Powershell Object using New-Object cmdlet.

$windowsUpdateObject = New-Object -ComObject Microsoft.Update.AutoUpdate

05-10-2013 00-22-27

My this new variable has a property of Results. So when I access the .Result property using dot notation, i have found the result what i was looking for,  The windows last Search success date and Windows update last installation date.

$windowsUpdateObject.Results

05-10-2013 00-58-11

 

$windowsUpdateObject.Results.LastInstallationSuccessDate

 

05-10-2013 00-27-33

 

$windowsUpdateObject.Results.LastSearchSuccessDate

 

05-10-2013 00-27-57

You can see the windows automatic basic setting using .Settings property.

$windowsUpdateObject.Settings

05-10-2013 01-03-07

The most cool thing which i have found is ShowSettingsDialog(), method. When you run this method it opens a Windows Update configuration GUI.

$windowsUpdateObject.ShowSettingsDialog()

05-10-2013 01-04-02

I hope you like it.

Thanks for your time and Happy Weekend.

Thanks

Aman Dhally

 

clip_image001 clip_image002 clip_image003 clip_image005  clip_image007

One thought on “Getting Last Installation Success Date and Last Search Success date of Windows Updates using Powershell.

  1. Hi Aman, great post. I have been using it on all versions of Windows and it works fine.

    However I have problems getting the value to update when I run a scan for updates using either PowerShell or any other way of automation using the API from Microsoft. It seems that the GUI is doing something extra when pressing the update button.
    Even the new USOClient.exe commend i Server 2016 dosen ‘t update the value.

    I have a workaround to pre 2016 because I know where the value is stores i Registry, so I can just perform a update myself.
    BUT in server 2016 that have changed.

    How to get the value to update either by an API or where is the value stored in 2016 ?

Comments are closed.