Script Library
Reviewed PowerShell Automation
Clear a Stuck Print Queue
Previews and removes queued jobs from one printer without restarting the Print Spooler or affecting other queues.
RemediationWindowsPowerShellModerate riskStandard userDry-run documented
What it does
- Verifies the selected printer exists
- Shows every job targeted for removal
- Removes only jobs from the named printer after confirmation
Required inputs
-PrinterName RequiredExact installed printer name shown by Get-Printer.
What it changes
- Permanently removes all queued jobs from the selected printer
- Does not remove the printer, driver, port, or jobs in other queues
Complete source
Read the entire script before copying or downloading it.
[CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact="High")]
param([Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()][string]$PrinterName)
$ErrorActionPreference = "Stop"
$printer = Get-Printer -Name $PrinterName -ErrorAction Stop
$jobs = @(Get-PrintJob -PrinterName $printer.Name -ErrorAction SilentlyContinue)
if ($jobs.Count -eq 0) { Write-Host "The '$($printer.Name)' queue is already empty."; return }
Write-Host "Jobs currently queued for '$($printer.Name)':"
$jobs | Select-Object Id, DocumentName, JobStatus, SubmittedTime | Format-Table -AutoSize
$target = "$($jobs.Count) job(s) in printer queue '$($printer.Name)'"
if ($PSCmdlet.ShouldProcess($target, "Permanently remove queued print jobs")) {
foreach ($job in $jobs) { Remove-PrintJob -PrinterName $printer.Name -ID $job.Id -Confirm:$false -ErrorAction Stop }
Write-Host "Removed $($jobs.Count) queued job(s). The printer, driver, and port were not changed."
}