Home > PowerShell > Use power shell to get installed patches from windows box

Use power shell to get installed patches from windows box

Today, I will take you through some of the PowerShell one-liners which will help you in querying patches installed in your machine.
 List All installed patches:

 
 PS C:>gwmi Win32_QuickFixEngineering | select Description, Hotfixid

 List all patches that are installed in last 30 days:

 PS C:> gwmi Win32_QuickFixEngineering | ? {$_.InstalledOn} | where { (Get-date($_.Installedon)) -gt (get-date).adddays(-30) }

 List all patches installed on specific date:

 PS C:> gwmi Win32_QuickFixEngineering | ? {$_.InstalledOn} | where { (Get-date($_.Installedon)) -gt (get-date 10/31/2009) }

Query for a specific hotfix by providing hotfix ID(KB12345 format):

PS C:> gwmi Win32_QuickFixEngineering | ? {$_.HotfixID -match ” KB975025″ }

List all hotfixes installed by administrator account:

PS C:> gwmi Win32_QuickFixEngineering | ? {$_.InstalledBy -match “administrator” }

You can adopt the above queries and run against remote machine by passing the computer name shown like below.
 PS C:> gwmi Win32_QuickFixEngineering -Computer remotecomp | ? {$_.InstalledOn} | where { (Get-date($_.Installedon)) -gt (get-date).adddays(-30) }

Happy Learning,
Sitaram Pamarthi

Categories: PowerShell
  1. Shaik
    October 8, 2011 at 12:40 pm | #1

    How can I get the details of last patch installed

    • Sitaram Pamarthi
      October 14, 2011 at 4:30 pm | #2

      Use this command to see last installed five patches.

      Get-HotFix | sort installedon -Descending | select -First 5

  1. No trackbacks yet.

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>