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