PowerShell Clear Print Jobs

  • Welcome to ITBible, we're your #1 resource for enterprise or homelab IT problems (or just a place to show off your stuff).
Have you ever wanted to run a script that would just clear the user's errored print queue? With this you can put it in your RMM and have it run against a users machine and the print server (so it clears out anything that is errored).

$PrintJobs = get-wmiobject -class "Win32_PrintJob" -namespace "root\CIMV2" -computername "."

foreach ($job in $PrintJobs) {
    $pos = ($job.Name).IndexOf(",")
    $printerName = ($job.Name).Substring(0, $pos)
    if($job.JobStatus -like "Error | Printing") {
        Write-Host "Canceling job $($job.JobId)"
        Remove-PrintJob -ComputerName $env:COMPUTERNAME -ID $job.JobId -PrinterName $printerName