Use PowerShell to remove a print job

Let’s suppose that one of the print jobs for the HP LaserJet 5200 printer had Error for its status. To determine which job it is, you can pipe the output from the Get-PrintJob cmdlet into the Where-Object cmdlet to display all jobs whose JobStatus property has “Error” in its value:

PS C:\> Get-PrintJob -ComputerName HOST7 -PrinterName “HP LaserJet 5200 PCL6” | `
where JobStatus -like “Error*”

Id   ComputerName  PrinterName     DocumentName   SubmittedTime       
JobStatus
   ————                ———–              ————                  ————-                  
———
3    HOST7                  HP LaserJet …  Document 3            8/26/2012 2:08:06 PM Error, Print…

Having determined that job #3 is the problem, you could now use the Remove-PrintJob cmdlet to cancel the problem job:

Remove-PrintJob -PrinterName “HP LaserJet 5200 PCL6” -ID 3

But instead of doing this, you can simply press the Up arrow to display the previously executed command and pipe its output into Remove-PrintJob as follows:

PS C:\> Get-PrintJob -ComputerName HOST7 -PrinterName “HP LaserJet 5200 PCL6” | `
where JobStatus -like “Error*” | Remove-PrintJob

Using the Get-PrintJob cmdlet again verifies that the problem has been resolved:

PS C:\> Get-PrintJob -ComputerName HOST7 -PrinterName “HP LaserJet 5200 PCL6”


Id   ComputerName   PrinterName     DocumentName   SubmittedTime       
JobStatus
   ————                 ———–               ————                 ————-                 
———
4    HOST7                   HP LaserJet …  Document 2          
8/26/2012 2:08:06 PM Printing
5    HOST7                   HP LaserJet …  Document 1           8/26/2012 2:08:06 PM Normal

The above tip was excerpted from Mitch Tulloch’s book Training Guide: Installing and Configuring Windows Server 2012 from Microsoft Press.

Mitch is a nine-time recipient of the Microsoft Most Valuable Professional (MVP) award and a widely recognized expert on Windows administration, deployment and virtualization.  For more information see http://www.mtit.com.

Leave a Comment

Your email address will not be published.

Scroll to Top