PowerShell: Print
- All command output is automatically printed to screen, unless the value is
$null
- To suppress output, see PowerShell: Suppress Command Output
Print to Screen
Write-Host
-
print to screen, but no output. Useful for printing status for user.
Write-Host 'hi'
print without a newline:
Write-Host 'hi' -nonewline
print a collection, one on each line:
# print a collection, one on each line Write-Host (1..5) -separator "`n"
Print to Screen or Pipe to Command
Write-Output
(aliasecho
,write
)-
print to screen or sent it to the pipeline.
usually not necessary, since that is default.
Command Output are Automatically Printed to Screen
Out-Host
-
send output to screen.
Out-Host
is automatically appended to every command that is executed.