← script library

Clear the Windows Update Cache with PowerShell

Self-Healing & RepairAugust 17, 2026

Stops the Windows Update service, removes the SoftwareDistribution folder and starts the service again, which is the standard fix for updates that fail to download or install with no useful error. The script refuses to run without administrator rights instead of failing halfway through.

powershell
# Clear the Windows Update cache
#-------------------------------------------------

$isadm = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if (-not $isadm) {
    Write-Host "<WRITE-LOG = ""*Please run this script as Administrator.*"">"
    Show-Warning "Please run this script as Administrator."
    Write-Host "<WRITE-LOG = ""*If this was a remote execution please provide Administrator credentials.*"">"
    Write-Error "Warning: Not running as Administrator."
} else {
	Stop-Service wuauserv -Force
	Remove-Item -Path "C:\Windows\SoftwareDistribution" -Recurse -Force
	Start-Service wuauserv
	Write-Host "Windows Update cache cleared!"
}

Run it across your fleet

This script runs as-is on a single host. Paste it into ServerEngine to schedule it, run it on a whole server group in parallel, and keep the credentials out of the file — see the scripts documentation and the credential store.

Ready when you are.

Try ServerEngine free for 7 days.