Saturday, October 5, 2013

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

1 comment:

  1. Hi Aman,

    I have been looking for a Powershell script just like this, this is a great script.
    My question is I would like to apply this script to several Windows Servers in my domain (these servers range from Windows 2003 up to Server 2012 R2). For example I have a text file named Computers.txt, which contains my list of servers. Is it possible to use a command such as get-content c:\Computers.txt and pipe the results to use to $windowsUpdateObject = New-Object -ComObject Microsoft.Update.AutoUpdate
    and $windowsUpdateObject.Results ?

    Please let me know if I am not clear.

    Thanks

    Kyza

    ReplyDelete

Note: Only a member of this blog may post a comment.