Echo in PowerShell: How Write-Output Works (With Examples)

You type echo in PowerShell out of CMD or Bash habit, and it mostly works. Then a sentence splits across three lines, or echo -n does nothing you expected.

Quick answer: echo is a built-in alias for Write-Output. It sends objects to the success stream (the pipeline). If nothing consumes them, they’re shown in the console:

echo 'Order 1001 shipped to Austin, TX'

We’ll cover how PowerShell echo differs from CMD, variables and line breaks, capturing output, function return values, -NoEnumerate (which behaves differently in Windows PowerShell 5.1), files, and what to use for color or no newline.

What You Need Before You Start

Any PowerShell version works, and no admin rights are needed. We tested in PowerShell 7.6 and Windows PowerShell 5.1. If you’re still choosing between the two output cmdlets, our Write-Host vs Write-Output comparison gives the short version.

Step 1: Print Text With echo and Write-Output

Write-Output, its echo alias and a bare string all do the same job. The fourth line proves the text really travels down the pipeline, because ForEach-Object receives it:

Write-Output 'Order 1001 shipped to Austin, TX'
echo 'Order 1002 shipped to Denver, CO'
'Order 1003 shipped to Seattle, WA'
Write-Output 'Order 1004 shipped to Miami, FL' | ForEach-Object { $_.ToUpper() }
'Aliases: ' + ((Get-Alias -Definition Write-Output).Name -join ', ')

Output:

Order 1001 shipped to Austin, TX
Order 1002 shipped to Denver, CO
Order 1003 shipped to Seattle, WA
ORDER 1004 SHIPPED TO MIAMI, FL
Aliases: echo, write
PowerShell Write-Output and echo alias examples in the console
Write-Output, echo and implicit output print the same way (PowerShell 7)

Microsoft lists echo on every platform and write on Windows only. Since a bare value is output anyway, echo is mostly about readability. For scripts you share, spell out Write-Output so the next reader knows exactly what runs.

How Is PowerShell echo Different From CMD echo?

CMD’s echo prints the rest of the line as plain text. PowerShell’s echo passes each space-separated word as its own argument, and dashes start parameter names. We ran the usual CMD and Bash habits in both shells:

echo Hello from Austin
echo "Hello from Austin"
cmd /c echo Hello from Austin
echo off
echo -n "No newline here?"
try { echo. } catch { 'echo.   -> Failed. ' + ($_.Exception.Message -split '[.,] ')[0] }
try { echo -e 'a' } catch { 'echo -e -> Failed. ' + ($_.Exception.Message -split '[.,] ')[0] }

Output in PowerShell 7:

Hello
from
Austin
Hello from Austin
Hello from Austin
off
No newline here?
echo.   -> Failed. The term 'echo.' is not recognized as a name of a cmdlet
echo -e -> Failed. Parameter cannot be processed because the parameter name 'e' is ambiguous
Windows PowerShell 5.1 echo without quotes, echo off, echo -n and echo. compared with cmd echo
echo without quotes prints one word per line, and echo. fails (Windows PowerShell 5.1)

The unquoted sentence came out one word per line, while cmd /c echo kept it on one. echo off just printed off, since PowerShell never echoes script commands, so you don’t need @echo off a