Get PrintJob - PowerShell


Overview

Get-PrintJob is a PowerShell cmdlet that retrieves information about print jobs managed by the local print spooler. It allows you to view the status, settings, and other details of printing tasks. This command is useful for managing print jobs, troubleshooting print-related issues, and gaining insights into the spooler’s behavior.

Syntax

Get-PrintJob [-Name] <string[]> [-User] <string[]> [-Printer] <string[]> [-Status] <string[]> [-Size] <string[]> [-TimeSubmitted] <DateTime[]> [-TimeCompleted] <DateTime[]> [-SizeInKBytes] <UInt32[]> [-Copies] <UInt32[]> [-Position] <UInt32[]> [-TotalPages] <UInt32[]> [-DocumentName] <string[]> [-Owner] <string[]> [-JobId] <int[]> [-IncludeArchivedJobs] [-ShowCompletedJobs]

Options/Flags

  • -Name: Filters results by print job name. Accepts an array of strings for multiple names.
  • -User: Filters results by the user who submitted the print job. Accepts an array of strings for multiple users.
  • -Printer: Filters results by the printer where the print job was sent. Accepts an array of strings for multiple printers.
  • -Status: Filters results by print job status, such as “Printing”, “Paused”, or “Completed”. Accepts an array of strings for multiple statuses.
  • -Size: Filters results by print job file size. Accepts an array of strings using comparison operators (<, >, =).
  • -TimeSubmitted: Filters results by the time the print job was submitted to the spooler. Accepts an array of DateTime objects for range filtering.
  • -TimeCompleted: Filters results by the time the print job was completed. Accepts an array of DateTime objects for range filtering.
  • -SizeInKBytes: Filters results by print job file size in kilobytes. Accepts an array of unsigned integers for range filtering.
  • -Copies: Filters results by the number of copies specified for the print job. Accepts an array of unsigned integers for range filtering.
  • -Position: Filters results by the position of the print job in the spooler queue. Accepts an array of unsigned integers for range filtering.
  • -TotalPages: Filters results by the total number of pages in the print job. Accepts an array of unsigned integers for range filtering.
  • -DocumentName: Filters results by the name of the document being printed. Accepts an array of strings for multiple document names.
  • -Owner: Filters results by the owner of the print job. Accepts an array of strings for multiple owners.
  • -JobId: Filters results by the unique ID of the print job. Accepts an array of integers for range filtering.
  • -IncludeArchivedJobs: Option to include archived print jobs in the results. Defaults to $false.
  • -ShowCompletedJobs: Option to include completed print jobs in the results. Defaults to $true.

Examples

Retrieve all active print jobs

Get-PrintJob

Get print job details for a specific printer

Get-PrintJob -Printer "MyPrinter"

Filter jobs by user and show completed jobs

Get-PrintJob -User "JohnDoe" -ShowCompletedJobs

Find jobs with a specific size range

Get-PrintJob -Size ">100KB" -Size "<500KB"

Retrieve job status and submission time

Get-PrintJob | Select Status, TimeSubmitted

Common Issues

Unable to retrieve print jobs

  • Ensure the print spooler service is running on the local machine.
  • The Get-PrintJob cmdlet requires elevated privileges (Run as Administrator).

Integration

Get-PrintJob integrates well with other PowerShell cmdlets, such as Restart-PrintJob, Pause-PrintJob, and Resume-PrintJob, to manage print jobs dynamically. It can be used in scripts to automate print job monitoring and management tasks.