Your strategic advantage starts here

Uninstall Windows Updates Based On Date

Uninstall Windows Updates Based On Date

I recently needed a quick PowerShell script to uninstall windows updates based on date.

In the example below, i wanted to uninstall any Windows Updates that had been installed on or after 01/01/2022.

cls

$ListOfHotfixes = Get-HotFix | Select hotfixid,description,installedby,@{label="InstalledOn";e={[DateTime]::Parse($_.psbase.properties["installedon"].value,$([System.Globalization.CultureInfo]::GetCultureInfo("en-US")))}} | Where-Object InstalledOn -gt ([DateTime]::Parse('01/01/2022'))


foreach ($item in $ListOfHotfixes)
{
    $hotfixid = $item.hotfixid
    write-host $hotfixid
    $hotfixidwithoutkb = $item.hotfixid.replace("KB","")

    Start-Process -FilePath "C:\Windows\System32\wusa.exe" -ArgumentList @("/uninstall","/kb:$hotfixidwithoutkb","/quiet","/norestart") -Wait

}
Related Posts
Leave a Reply
Give us a call

Available from 9am to 8pm, Monday to Friday.

Send us a message

Send your message any time you want.

Our usual reply time: 1 Business day
Give us a call

Available from 9am to 8pm, Monday to Friday.

Send us a message

Send your message any time you want.

Our usual reply time: 1 Business day