Out-Printer

Sends output to a printer.

语法

Default (默认值)

Out-Printer
    [[-Name] <String>]
    [-InputObject <PSObject>]
    [<CommonParameters>]

说明

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.

示例

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-Contentgets 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.

参数

-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.

参数属性

类型:PSObject
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:True
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Name

Sends the output to the specified printer. The parameter name Name is optional.

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False
别名:PrinterName

参数集

(All)
Position:0
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

输入

PSObject

You can pipe any object to this cmdlet.

输出

None

This cmdlet returns no output.

备注

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.