A collection of detection and remediation scripts for use with Microsoft Intune's Proactive Remediations (now called Remediations in the Intune admin center).
How remediations work
Each remediation pair consists of two PowerShell scripts:
- Detection script — exits with code
1if the issue is detected,0if healthy. - Remediation script — runs only when detection exits
1. Should fix the problem and exit0.
Example: clear Windows Update cache
# detect.ps1
$path = "C:\Windows\SoftwareDistribution\Download"
$items = Get-ChildItem $path -ErrorAction SilentlyContinue
if ($items.Count -gt 0) { exit 1 } else { exit 0 }
# remediate.ps1
Stop-Service -Name wuauserv -Force
Remove-Item "C:\Windows\SoftwareDistribution\Download\*" -Recurse -Force
Start-Service -Name wuauserv
exit 0
Add your own scripts here — duplicate the heading and code block pattern above for each script pair.