Out-Host
Sends output to the command line.
Syntax
Out-Host
[-Paging]
[-InputObject <PSObject>]
[<CommonParameters>]
Description
The Out-Host
cmdlet sends output to the PowerShell host for display. The host displays the output
at the command line. Because Out-Host
is the default, you don't have to specify it unless you want
to use its parameters.
Out-Host
is automatically appended to every command that is executed. It passes the output of the
pipeline to the host executing the command. Out-Host
ignores ANSI escape sequences. The escape
sequences are handled by the host. Out-Host
passes ANSI escape sequences to the host without
trying to interpret or change them.
Examples
Example 1: Display output one page at a time
This example displays the system processes one page at a time.
Get-Process | Out-Host -Paging
NPM(K) PM(M) WS(M) CPU(s) Id SI ProcessName
------ ----- ----- ------ -- -- -----------
30 24.12 36.95 15.86 21004 14 ApplicationFrameHost
55 24.33 60.48 10.80 12904 14 BCompare
<SPACE> next page; <CR> next line; Q quit
9 4.71 8.94 0.00 16864 14 explorer
<SPACE> next page; <CR> next line; Q quit
Get-Process
gets the system processes and sends the objects down the pipeline. Out-Host
uses the
Paging parameter to display one page of data at a time.
Example 2: Use a variable as input
This example uses objects stored in a variable as the input for Out-Host
.
$io = Get-History
Out-Host -InputObject $io
Get-History
gets the PowerShell session's history, and stores the objects in the $io
variable.
Out-Host
uses the InputObject parameter to specify the $io
variable and displays the
history.
Parameters
-InputObject
Specifies the objects that are written to the console. 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 |
-Paging
Indicates that Out-Host
displays one page of output at a time, and waits for user input before the
remaining pages are displayed. By default, all the output is displayed on a single page. The page
size is determined by the characteristics of the host.
Press the Space bar to display the next page of output or the Enter key to view the next line of output. Press Q to quit.
Paging is similar to the more command.
Note
The Paging parameter isn't supported by the PowerShell ISE host.
Type: | SwitchParameter |
Position: | Named |
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. It sends objects to the host for display.
Notes
PowerShell includes the following aliases for Out-Host
:
- All platforms:
oh
The Paging parameter isn't supported by all PowerShell hosts. For example, if you use the
Paging parameter in the PowerShell ISE, the following error is displayed:
out-lineoutput : The method or operation is not implemented.
The cmdlets that contain the Out verb, Out-
, don't format objects. They render objects 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.
The Out-
cmdlets don't have parameters for names or file paths. To send data to an Out-
cmdlet,
use the pipeline to send a PowerShell command's output to the cmdlet. Or, you can store data in a
variable and use the InputObject parameter to pass the data to the cmdlet.
Out-Host
sends data, but it doesn't produce any output objects. If you pipeline the output of
Out-Host
to the Get-Member
cmdlet, Get-Member
reports that no objects have been specified.
Related Links
PowerShell