PrintTestPage method of the Win32_Printer Class
Applies to: desktop apps only
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
uint32 PrintTestPage();
Parameters
This method has no parameters.
Return value
| Return code | Description |
|---|---|
|
Success |
|
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 client | Windows XP |
|---|---|
|
Minimum supported server | Windows Server 2003 |
|
Namespace |
\root\CIMV2 |
|
MOF |
|
|
DLL |
|
See also
Send comments about this topic to Microsoft
Build date: 3/9/2012
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
- 4/13/2007
- Thomas Lee