← script library

Clear a Stuck Print Queue with PowerShell

Self-Healing & RepairAugust 17, 2026

Counts the stuck spool files first and leaves the spooler alone when there are none, then stops the service, deletes the queue files, starts it again and verifies it came back. Restarting the spooler unconditionally is what turns one stuck job into every user losing theirs.

powershell
# Clear Stuck Print Queue
# Single use case: stop spooler, purge stuck jobs, start spooler
#-----------------------------------------------------------------

function Write-Log {
    param($Message)
    Write-Host "<WRITE-LOG = `"*$Message*`">"
}

$spooler = Get-Service -Name Spooler -ErrorAction SilentlyContinue
if ($null -eq $spooler) {
    Write-Log "Print Spooler service not found on this host."
    return
}

$queueDir = "$env:SystemRoot\System32\spool\PRINTERS"
$stuck = @(Get-ChildItem $queueDir -File -ErrorAction SilentlyContinue)
Write-Log "Stuck spool files found: $($stuck.Count)"

if ($stuck.Count -eq 0) {
    Write-Log "Print queue is already clean - spooler untouched."
    return
}

Write-Log "Stopping Print Spooler..."
Stop-Service -Name Spooler -Force -ErrorAction SilentlyContinue
Start-Sleep 2

$stuck | Remove-Item -Force -ErrorAction SilentlyContinue
$left = @(Get-ChildItem $queueDir -File -ErrorAction SilentlyContinue).Count
Write-Log "Spool files removed: $($stuck.Count - $left) (remaining: $left)"

Write-Log "Starting Print Spooler..."
Start-Service -Name Spooler -ErrorAction SilentlyContinue
Start-Sleep 2

$spooler = Get-Service -Name Spooler
if ($spooler.Status -eq "Running") {
    Write-Log "Print queue cleared and spooler running again."
} else {
    Write-Log "WARNING: spooler is $($spooler.Status) after cleanup!"
}

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.