goguppy.com ← scripts and remediations

🖨️ Restart Spooler

Intune Remediation · Restarts the print spooler and clears jobs stuck over 20 minutes
Test in a pilot group before you point this at the fleet. Detection exits 1 to trigger remediation, 0 to stay put.
Detection Script
D
Detect stopped spooler or stuck jobs detection
Exits 1 when the service is stopped or a job has sat unwritten for 20 minutes.
# Flags a stopped spooler or jobs stuck 20 minutes. if ((Get-Service Spooler).Status -ne 'Running') { exit 1 } $f = Get-ChildItem "$env:SystemRoot\System32\spool\PRINTERS" -Filter *.SPL -ErrorAction SilentlyContinue | Where-Object { $_.LastWriteTime -lt (Get-Date).AddMinutes(-20) } if ($f) { exit 1 } else { exit 0 }
Remediation Script
R
Clear the queue and restart the spooler remediation
Runs only when detection exits 1.
# Clears the print queue and restarts the spooler. Stop-Service Spooler -Force Remove-Item "$env:SystemRoot\System32\spool\PRINTERS\*" -Force -ErrorAction SilentlyContinue Start-Service Spooler
Intune Remediation Settings
Run this script using the logged on credentials No
Enforce script signature check No
Run script in 64-bit PowerShell host Yes
Schedule (recommended) Hourly