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