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, InstallDateExamples
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, InstallDateThe 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, ReturnTypeProperties
| Name | Type | Access | Description | |||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Caption# | string | read | A short textual description of the object. Code | |||||||||||||||||||||||||||||||||||||||
| Color# | string | read | 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)
Code | |||||||||||||||||||||||||||||||||||||||
| DataType# | string | read | 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 | |||||||||||||||||||||||||||||||||||||||
| Description# | string | read | A textual description of the object. Code | |||||||||||||||||||||||||||||||||||||||
| Document# | string | read | 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 | |||||||||||||||||||||||||||||||||||||||
| DriverName# | string | read | Name of the printer driver used for the print job. Code | |||||||||||||||||||||||||||||||||||||||
| ElapsedTime# | datetime | read | Length of time the job has been executing. Code | |||||||||||||||||||||||||||||||||||||||
| HostPrintQueue# | string | read | Name of the computer on which the print job is created. Code | |||||||||||||||||||||||||||||||||||||||
| InstallDate# | datetime | read | Indicates when the object was installed. Lack of a value does not indicate that the object is not installed. Code | |||||||||||||||||||||||||||||||||||||||
| JobId# | uint32 | read | Identifier number of the job. It is used by other methods as a handle to a job spooling to the printer. Code | |||||||||||||||||||||||||||||||||||||||
| JobStatus# | string | read | Free-form string that represents the job status. Code | |||||||||||||||||||||||||||||||||||||||
| Name# | string | read | Label by which the object is known. When subclassed, this property can be overridden to be a key property. Code | |||||||||||||||||||||||||||||||||||||||
| Notify# | string | read | User is notified upon job completion or failure. Code | |||||||||||||||||||||||||||||||||||||||
| Owner# | string | read | User who submitted the job. Code | |||||||||||||||||||||||||||||||||||||||
| PagesPrinted# | uint32 | read | Number of pages that are printed. This value may be 0 (zero) if the print job does not contain page-delimiting information. Code | |||||||||||||||||||||||||||||||||||||||
| PaperLength# | uint32 | read | Length of the paper. Example: 2794 Code | |||||||||||||||||||||||||||||||||||||||
| PaperSize# | string | read | 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 | |||||||||||||||||||||||||||||||||||||||
| PaperWidth# | uint32 | read | Width of the paper. Example: 2159 Code | |||||||||||||||||||||||||||||||||||||||
| Parameters# | string | read | Optional parameters to send to the print processor. For more information, see the PrintProcessor property. Code | |||||||||||||||||||||||||||||||||||||||
| PrintProcessor# | string | read | 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 | |||||||||||||||||||||||||||||||||||||||
| Priority# | uint32 | read | Importance of a job's execution. Code | |||||||||||||||||||||||||||||||||||||||
| Size# | uint32 | read | Size of the print job. Code | |||||||||||||||||||||||||||||||||||||||
| StartTime# | datetime | read | Time that the job began. Code | |||||||||||||||||||||||||||||||||||||||
| Status# | string | read | 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)
Code | |||||||||||||||||||||||||||||||||||||||
| StatusMask# | uint32 | read | Bitmap of the possible statuses that relate to this print job. Values (12)
Code | |||||||||||||||||||||||||||||||||||||||
| TimeSubmitted# | datetime | read | Time that the job was submitted. Code | |||||||||||||||||||||||||||||||||||||||
| TotalPages# | uint32 | read | 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 | |||||||||||||||||||||||||||||||||||||||
| UntilTime# | datetime | read | Time at which the job is invalid or should be stopped. Code |
Methods
Pause #
Pauses a print job.
uint32 Pause();Return values
| Value | Label | Description |
|---|---|---|
| 0 | Success | |
| 5 | Access 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
| Value | Label | Description |
|---|---|---|
| 0 | Success | |
| 5 | Access 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
- CIM_ManagedSystemElement
- CIM_LogicalElement
- CIM_Job
- 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
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.