Out-Printer
Sends output to a printer.
Syntax
Out-Printer
[[-Name] <String>]
[-InputObject <PSObject>]
[<CommonParameters>]
Description
This cmdlet is only available on the Windows platform.
The Out-Printer
cmdlet sends output to the default printer or to an alternate printer, if one is
specified. Since the cmdlet doesn't have any way to configure the print job, the resulting print job
uses the default settings defined for the printer.
Note
This cmdlet was reintroduced in PowerShell 7. This cmdlet is only available on Windows systems that support the Windows Desktop.
Examples
Example 1 - Send a file to be printed on the default printer
This example shows how to print a file, even though Out-Printer
does not have a Path
parameter.
Get-Content -Path ./readme.txt | Out-Printer
Get-Content
gets the contents of the readme.txt
file in the current directory and pipes it to
Out-Printer
, which sends it to the default printer.
Example 2: Print a string to a remote printer
This example prints Hello, World
to the Prt-6B Color printer on Server01.
"Hello, World" | Out-Printer -Name "\\Server01\Prt-6B Color"
The Name parameter selects a specific printer, rather than the default.
Example 3 - Print a help topic to the default printer
This example prints the full version of the Help topic for Get-CimInstance
.
$H = Get-Help -Full Get-CimInstance
Out-Printer -InputObject $H
Get-Help
gets the full version of the Help topic for Get-CimInstance
and stores it in the $H
variable. The InputObject parameter passes the value of $H
to Out-Printer
.
Parameters
-InputObject
Specifies the objects to be sent to the printer. Enter a variable that contains the objects, or type a command or expression that gets the objects.
Type: | PSObject |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-Name
Sends the output to the specified printer. The parameter name Name is optional.
Type: | String |
Aliases: | PrinterName |
Position: | 0 |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Inputs
You can pipe any object to this cmdlet.
Outputs
None
This cmdlet returns no output.
Notes
This cmdlet is only available on Windows platforms.
The cmdlets that contain the Out
verb do not format objects. They just render them and send them
to the specified display destination. If you send an unformatted object to an Out
cmdlet, the
cmdlet sends it to a formatting cmdlet before rendering it.
Out-Printer
sends data to the printer, but does not emit any output objects to the pipeline. If
you pipe the output of Out-Printer
to Get-Member
, Get-Member
reports that no objects have been
specified.