PrintTestPage Method of the Win32_Printer Class

The PrintTestPage WMI class method prints a test page.

This topic uses Managed Object Format (MOF) syntax. For more information about using this method, see Calling a Method.

Syntax

MOF
uint32 PrintTestPage();

Parameters

This method has no parameters.

Return Value

Returns one of the values listed in the following table, or any other value to indicate an error.

Return codeDescription
0

Success

5

Access Denied

 

Examples

For script code examples, see WMI Tasks for Scripts and Applications and the TechNet ScriptCenter Script Repository.

For C++ code examples, see WMI C++ Application Examples.

Requirements

Minimum supported clientWindows XP
Minimum supported serverWindows Server 2003
MOFCimwin32.mof
DLLCimwin32.dll
Namespace\root\cimv2

See Also

Computer System Hardware Classes
Win32_Printer

 

 

Send comments about this topic to Microsoft

Build date: 1/8/2010

Build type: MSDN

Tags :


Community Content

Thomas Lee
Win32_Printer WMI class PrintTestPage Method using PowerShell
# wmi-printtestpage.ps1
# Demonstrates how to print a test page using WMI and PowerShell
# Thomas Lee - tfl@psp.co.uk
 
# Get printer objects from  WMI
$printers=Get-WmiObject Win32_Printer
"{0} Printers defined on this system" -f $printers.count
 
# Get a specific printer
$printer = $printers | where {$_.name -eq "\\smallguy\HP LaserJet 5M"}
 
# Display info
"Printer share name: {0}\{1}" -f $printer.servername, $printer.sharename
"Printer Port      : {0}    " -f $printer.PortName
  
# Print a test page
$printer.PrintTestPage()


When run this script produced the following output (and a test page printed on the printer)

 
PSH [D:\foo]: .\wmi-printtestpage.ps1
15 Printers defined on this system
Printer share name: \\smallguy\HPLaserJ
Printer Port      : 192.168.1.9:HPLaserj

Page view tracker