Win32_PrintJob

Win32 Print Job

Represents a print job generated by a Windows application. Any unit of work generated by the print command of an application that is running on a computer running on a Windows operating system is a descendant or member of this class.

On this page

Main example

List instances

# All instances of Win32_PrintJob, with the main properties
Get-CimInstance -ClassName Win32_PrintJob |
    Select-Object -Property Name, Caption, Description, Status, Size, InstallDate

Examples

Filter with WQL

# WQL filter evaluated by the provider: StatusMask = 1 (Paused)
Get-CimInstance -ClassName Win32_PrintJob -Filter 'StatusMask = 1' |
    Select-Object -Property Name, Caption, Description, Status, Size, InstallDate

The filter is evaluated by the WMI provider: less data is transferred than with Where-Object.

Decode numeric values

# Lookup table for StatusMask (values documented by Microsoft)
$statusMaskName = @{
    1 = 'Paused'
    2 = 'Error'
    4 = 'Deleting'
    8 = 'Spooling'
    16 = 'Printing'
    32 = 'Offline'
    64 = 'Paperout'
    128 = 'Printed'
    256 = 'Deleted'
    512 = 'Blocked_DevQ'
    1024 = 'User_Intervention_Req'
    2048 = 'Restart'
}

Get-CimInstance -ClassName Win32_PrintJob |
    Select-Object -Property @(
        'Name'
        'Caption'
        'Description'
        'Status'
        'Size'
        'InstallDate'
        @{ Name = 'StatusMask'; Expression = { $statusMaskName[[int]$_.StatusMask] } }
    )

Query a remote computer (CIM session)

review before running
# Name of the remote computer
$computerName = 'SERVER01'
# The CIM session (WSMan by default) can be reused for several queries
$cimSession = New-CimSession -ComputerName $computerName
try {
    Get-CimInstance -CimSession $cimSession -ClassName Win32_PrintJob |
        Select-Object -Property Name, Caption, Description, Status, Size, InstallDate
} finally {
    Remove-CimSession -CimSession $cimSession
}

WSMan (WinRM) is used by default. For a host without WinRM, create the session with -SessionOption (New-CimSessionOption -Protocol Dcom). Add -Credential to use another account.

Show the class structure

# Class structure: properties, types and flags (Key, ReadOnly…)
$cimClass = Get-CimClass -ClassName Win32_PrintJob
$cimClass.CimClassProperties |
    Select-Object -Property Name, CimType, Flags

# Methods of the class
$cimClass.CimClassMethods |
    Select-Object -Property Name, ReturnType

Properties

28 of 28 properties
NameTypeAccessDescription
Captionstringread

A short textual description of the object.

Code
# Value of Caption for each instance
Get-CimInstance -ClassName Win32_PrintJob -Property Name, Caption |
    Select-Object -Property Name, Caption
Colorstringread

String that indicates whether the document is printed in color or monochrome. Some color printers have the capability to print using true black instead of a combination of yellow, cyan, and magenta. True black usually creates darker and sharper text for documents. This option is only useful for color printers that support true black printing.

The values are:

Values (2)
ValueLabelDescription
"Color"
"Monochrome"
Code
# Value of Color for each instance
Get-CimInstance -ClassName Win32_PrintJob -Property Name, Color |
    Select-Object -Property Name, Color
DataTypestringread

Format of the data for this print job. This instructs the printer driver to translate the data (generic text, PostScript, or PCL) before printing, or print in a raw format (for graphics and pictures).

Example: "TEXT"

Code
# Value of DataType for each instance
Get-CimInstance -ClassName Win32_PrintJob -Property Name, DataType |
    Select-Object -Property Name, DataType
Descriptionstringread

A textual description of the object.

Code
# Value of Description for each instance
Get-CimInstance -ClassName Win32_PrintJob -Property Name, Description |
    Select-Object -Property Name, Description
Documentstringread

Name of the print job. The user sees this name when viewing documents that are waiting to be printed.

Example: "Microsoft Word - Review.doc"

Code
# Value of Document for each instance
Get-CimInstance -ClassName Win32_PrintJob -Property Name, Document |
    Select-Object -Property Name, Document
DriverNamestringread

Name of the printer driver used for the print job.

Code
# Value of DriverName for each instance
Get-CimInstance -ClassName Win32_PrintJob -Property Name, DriverName |
    Select-Object -Property Name, DriverName
ElapsedTimedatetimeread

Length of time the job has been executing.

Code
# Value of ElapsedTime for each instance
# CIM cmdlets already return a DateTime object: no conversion is needed
Get-CimInstance -ClassName Win32_PrintJob -Property Name, ElapsedTime |
    Select-Object -Property Name, ElapsedTime
HostPrintQueuestringread

Name of the computer on which the print job is created.

Code
# Value of HostPrintQueue for each instance
Get-CimInstance -ClassName Win32_PrintJob -Property Name, HostPrintQueue |
    Select-Object -Property Name, HostPrintQueue
InstallDatedatetimeread

Indicates when the object was installed. Lack of a value does not indicate that the object is not installed.

Code
# Value of InstallDate for each instance
# CIM cmdlets already return a DateTime object: no conversion is needed
Get-CimInstance -ClassName Win32_PrintJob -Property Name, InstallDate |
    Select-Object -Property Name, InstallDate
JobIduint32read

Identifier number of the job. It is used by other methods as a handle to a job spooling to the printer.

Code
# Value of JobId for each instance
Get-CimInstance -ClassName Win32_PrintJob -Property Name, JobId |
    Select-Object -Property Name, JobId
JobStatusstringread

Free-form string that represents the job status.

Code
# Value of JobStatus for each instance
Get-CimInstance -ClassName Win32_PrintJob -Property Name, JobStatus |
    Select-Object -Property Name, JobStatus
Namestringread

Label by which the object is known. When subclassed, this property can be overridden to be a key property.

Code
# Value of Name for each instance
Get-CimInstance -ClassName Win32_PrintJob -Property Name |
    Select-Object -Property Name
Notifystringread

User is notified upon job completion or failure.

Code
# Value of Notify for each instance
Get-CimInstance -ClassName Win32_PrintJob -Property Name, Notify |
    Select-Object -Property Name, Notify
Ownerstringread

User who submitted the job.

Code
# Value of Owner for each instance
Get-CimInstance -ClassName Win32_PrintJob -Property Name, Owner |
    Select-Object -Property Name, Owner
PagesPrinteduint32read

Number of pages that are printed. This value may be 0 (zero) if the print job does not contain page-delimiting information.

Code
# Value of PagesPrinted for each instance
Get-CimInstance -ClassName Win32_PrintJob -Property Name, PagesPrinted |
    Select-Object -Property Name, PagesPrinted
PaperLengthuint32read

Length of the paper.

Example: 2794

Code
# Value of PaperLength for each instance
Get-CimInstance -ClassName Win32_PrintJob -Property Name, PaperLength |
    Select-Object -Property Name, PaperLength
PaperSizestringread

Size of the paper used to print the job. The value is one of the possible paper sizes for the printer specified in the PaperSizesSupported property of Win32_Printer class.

Code
# Value of PaperSize for each instance
Get-CimInstance -ClassName Win32_PrintJob -Property Name, PaperSize |
    Select-Object -Property Name, PaperSize
PaperWidthuint32read

Width of the paper.

Example: 2159

Code
# Value of PaperWidth for each instance
Get-CimInstance -ClassName Win32_PrintJob -Property Name, PaperWidth |
    Select-Object -Property Name, PaperWidth
Parametersstringread

Optional parameters to send to the print processor. For more information, see the PrintProcessor property.

Code
# Value of Parameters for each instance
Get-CimInstance -ClassName Win32_PrintJob -Property Name, Parameters |
    Select-Object -Property Name, Parameters
PrintProcessorstringread

Print processor service used to process the print job. A printer processor works in conjunction with the printer driver to provide additional translation of printer data for the printer, and can also be used to provide special options, such as a title page for the job.

Code
# Value of PrintProcessor for each instance
Get-CimInstance -ClassName Win32_PrintJob -Property Name, PrintProcessor |
    Select-Object -Property Name, PrintProcessor
Priorityuint32read

Importance of a job's execution.

Code
# Value of Priority for each instance
Get-CimInstance -ClassName Win32_PrintJob -Property Name, Priority |
    Select-Object -Property Name, Priority
Sizeuint32read

Size of the print job.

Code
# Value of Size for each instance
Get-CimInstance -ClassName Win32_PrintJob -Property Name, Size |
    Select-Object -Property Name, Size
StartTimedatetimeread

Time that the job began.

Code
# Value of StartTime for each instance
# CIM cmdlets already return a DateTime object: no conversion is needed
Get-CimInstance -ClassName Win32_PrintJob -Property Name, StartTime |
    Select-Object -Property Name, StartTime
Statusstringread

String that indicates the current status of the object. Operational and non-operational status can be defined. Operational status can include "OK", "Degraded", and "Pred Fail". "Pred Fail" indicates that an element is functioning properly, but is predicting a failure (for example, a SMART-enabled hard disk drive).

Non-operational status can include "Error", "Starting", "Stopping", and "Service". "Service" can apply during disk mirror-resilvering, reloading a user permissions list, or other administrative work. Not all such work is online, but the managed element is neither "OK" nor in one of the other states.

Values include the following:

Values (12)
ValueLabelDescription
OKOK
ErrorError
DegradedDegraded
UnknownUnknown
Pred FailPred Fail
StartingStarting
StoppingStopping
ServiceService
StressedStressed
NonRecoverNonRecover
No ContactNo Contact
Lost CommLost Comm
Code
# Value of Status for each instance
Get-CimInstance -ClassName Win32_PrintJob -Property Name, Status |
    Select-Object -Property Name, Status
StatusMaskuint32read

Bitmap of the possible statuses that relate to this print job.

Values (12)
ValueLabelDescription
1Paused
2Error
4Deleting
8Spooling
16Printing
32Offline
64Paperout
128Printed
256Deleted
512Blocked_DevQ
1024User_Intervention_Req
2048Restart
Code
# Value of StatusMask for each instance
# Lookup table for StatusMask (values documented by Microsoft)
$statusMaskName = @{
    1 = 'Paused'
    2 = 'Error'
    4 = 'Deleting'
    8 = 'Spooling'
    16 = 'Printing'
    32 = 'Offline'
    64 = 'Paperout'
    128 = 'Printed'
    256 = 'Deleted'
    512 = 'Blocked_DevQ'
    1024 = 'User_Intervention_Req'
    2048 = 'Restart'
}
Get-CimInstance -ClassName Win32_PrintJob -Property Name, StatusMask |
    Select-Object -Property @(
        'Name'
        @{ Name = 'StatusMask'; Expression = { $statusMaskName[[int]$_.StatusMask] } }
    )
TimeSubmitteddatetimeread

Time that the job was submitted.

Code
# Value of TimeSubmitted for each instance
# CIM cmdlets already return a DateTime object: no conversion is needed
Get-CimInstance -ClassName Win32_PrintJob -Property Name, TimeSubmitted |
    Select-Object -Property Name, TimeSubmitted
TotalPagesuint32read

Number of pages required to complete the job. This value may be 0 (zero) if the print job does not contain page-delimiting information.

Code
# Value of TotalPages for each instance
Get-CimInstance -ClassName Win32_PrintJob -Property Name, TotalPages |
    Select-Object -Property Name, TotalPages
UntilTimedatetimeread

Time at which the job is invalid or should be stopped.

Code
# Value of UntilTime for each instance
# CIM cmdlets already return a DateTime object: no conversion is needed
Get-CimInstance -ClassName Win32_PrintJob -Property Name, UntilTime |
    Select-Object -Property Name, UntilTime

Methods

Pause #

Pauses a print job.

uint32 Pause();

Return values

ValueLabelDescription
0Success
5Access Denied

Call the Pause method

review before running
# Warning: this method can change the system. -WhatIf shows the operation without running it.
# Target instance
$instance = Get-CimInstance -ClassName Win32_PrintJob
$methodParameters = @{
    InputObject = $instance
    MethodName  = 'Pause'
    WhatIf      = $true  # Remove this line to actually run the method
}
$result = Invoke-CimMethod @methodParameters

# With -WhatIf nothing runs and no result is returned
if ($result) {
    $returnValueName = @{
        0 = 'Success'
        5 = 'Access Denied'
    }
    $returnValueName[[int]$result.ReturnValue]
}

This method can change the system. The -WhatIf parameter shows the operation without running it: remove it only after checking.

Resume #

Continues a print job.

uint32 Resume();

Return values

ValueLabelDescription
0Success
5Access Denied

Call the Resume method

review before running
# Warning: this method can change the system. -WhatIf shows the operation without running it.
# Target instance
$instance = Get-CimInstance -ClassName Win32_PrintJob
$methodParameters = @{
    InputObject = $instance
    MethodName  = 'Resume'
    WhatIf      = $true  # Remove this line to actually run the method
}
$result = Invoke-CimMethod @methodParameters

# With -WhatIf nothing runs and no result is returned
if ($result) {
    $returnValueName = @{
        0 = 'Success'
        5 = 'Access Denied'
    }
    $returnValueName[[int]$result.ReturnValue]
}

This method can change the system. The -WhatIf parameter shows the operation without running it: remove it only after checking.

Remarks

The Win32_PrintJob class is derived from CIM_Job.

Inheritance

Superclass chain

  1. CIM_ManagedSystemElement
  2. CIM_LogicalElement
  3. CIM_Job
  4. Win32_PrintJob

Known subclasses

No known subclass.

Requirements

Namespace
root/cimv2
Minimum client
Windows Vista
Minimum server
Windows Server 2008
MOF file
Win32_Printer.mof
DLL
CIMWin32.dll

Microsoft source

Source: Microsoft Learn

Descriptions, properties and methods come from the Microsoft documentation (MicrosoftDocs/win32 repository), published under the CC BY 4.0 licence. Formatting and translations are specific to this site; the PowerShell examples are written for it.