Clear all print jobs using PowerShell

Note: Cmdlet is available on Windows server 2012 but works remotely for previous versions.

Windows Server 2012 has a new cmdlet Remove-PrintJob that helps delete the print jobs on the server. You need to specify either the Job ID or the Printer name.

Example: Remove-PrintJob -ComputerName tctp22wspsx01 -PrinterName <TestPrinter> -ID 2

Clear all print jobs on the server

The command below removes all the print jobs on remote computer.
Get-Printer -ComputerName <SystemName>| Get-PrintJob | Remove-PrintJob

or

Removes all print jobs on the local system.
Get-Printer | Get-PrintJob | Remove-PrintJob

The above commands gets the list of printers on the system, pass it on the to next cmdlet which retrieves the print jobs on each of the printer. These jobs are then passed on to next cmdlet which finally removes the passed print jobs on the specified computer.

Clear all print jobs older than X days

Below example delete all print jobs older than 1 day:

Get-Printer -ComputerName PrintServer1 | get-printjob | where{$_.SubmittedTime -lt ((Get-Date).adddays(-1))} | Remove-PrintJob

(Get-Date).AddDays(-1)  – Change the value –1 to increase the number of days.