Skip to content

Instantly share code, notes, and snippets.

@SMSAgentSoftware
Last active May 31, 2023 10:09
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SMSAgentSoftware/982742af3f30c26b279a9acf9d9e60f3 to your computer and use it in GitHub Desktop.
Save SMSAgentSoftware/982742af3f30c26b279a9acf9d9e60f3 to your computer and use it in GitHub Desktop.
PowerShell 'one-liner' to get Windows Update history using the PackageManagement module
Get-Package -ProviderName msu |
Select Name,
@{l='UpdateType';e={
If ($_.Name -match "Antivirus" -or $_.Name -match "antimalware")
{"Definition Update"}
ElseIf ($_.Metadata.Item("SupportUrl") -match "target=hub")
{"Driver Update"}
ElseIf ($_.Summary -match "latest version of Windows")
{"Feature Update"}
ElseIf ($_.Name -match "Malicious Software Removal" -or $_.Name -match "Intelligence Update")
{"Other Update"}
Else {"Quality Update"}
}
},
@{l='InstallDate';e={[DateTime]::Parse($_.Metadata.Item("Date"))}},
@{l='ResultCode';e={$_.Metadata.Item("ResultCode")}},
Status,
@{l='SupportUrl';e={$_.Metadata.Item("SupportUrl")}},
Summary |
Sort -Property UpdateType,InstallDate -Descending |
Out-GridView
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment