Taking on PowerShell one cmdlet at a time

Share this post: This is part of an ongoing blog series by Adam Gordon. Adam will walk through each PowerShell command every week, explaining when and how to use them. Adam will be covering Out-Host this week.

When should you use Out-Host?
The Out-Host cmdlet sends the output to the PowerShell host. The command line displays the output from the host. You don’t need to specify Out-Host unless you wish to use its parameters.
Every command executed automatically adds Out-Host. It transmits the output of the pipeline the host that executes the command. Out-Host ignores ANSI escape sequences.
The host handles the escape sequences. Out-Host gives the host the ANSI escape sequences, without trying to modify or interpret them.
What version of PowerShell should I use for this blog?
Get the PowerShell Version for your machine
This command displays the PowerShell version information for your machine.

How to use Out-Host
Display output one page at time
Get-Process | Out-Host -Paging

Get-Process sends the objects down to the pipeline and gets the system processing. Out-Host uses -Paging to display one page at a time.
As an input, use a variable
$io = Get-History
Out-Host -InputObject $io

Get-History retrieves the PowerShell session’s history and stores them in the $io variable. Out-Host uses -InputObject to specify the $io variables and displays the history.
Learn the command from last week: Set-StrictMode.
Do you need PowerShell training? ITProTV offers PowerShell online IT training courses.