0

I'm trying to make a script on PowerShell, I need to on click, check every single spool queue, and inside of that check if the jobs are ok, if not proceed to erase the jobs with errors or blocked...so far I can't achieve this, is only looking for the printer itself, so I don't have idea to make the script check inside the jobs.

Get-Printer | Get-PrintJob | where {$_.JobStatus -match "Error"} | Remove-PrintJob
Get-Printer | where {$_.PrinterStatus -ne "Normal"} | Get-Printjob |Remove-PrintJob
Get-Printer -ComputerName MYNAME| Get-PrintJob | Remove-PrintJob

Get-Printer | Get-PrintJob | where {$_.JobStatus -match "Sent to printer"} | Remove-PrintJob

Get-Printer | where {$_.PrinterStatus -ne "Printing"} | Get-Printjob | Remove-PrintJob
Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
José Vieiros
  • 75
  • 1
  • 13

1 Answers1

0

Get-Printer | Get-PrintJob | Where-Object {$_.JobStatus -like "Error*"} | Remove-PrintJob

I used {$_.JobStatus -like "Error*"} because a printer maybe has more than a stat, but error is the first.

raellage
  • 1
  • 1