As a PowerShell developer or admin, you should know the differences between Write-Host and Write-Output. In this tutorial, I will explain everything about PowerShell Write-Host vs Write-Output with examples.
What is Write-Host in PowerShell?
The Write-Host cmdlet is used to display text directly to the console. It is used to produce output that is meant for human eyes rather than to pass data along a pipeline or store it in variables.
This makes Write-Host ideal for creating user prompts or for displaying messages that don’t need to be processed further.
For example, let’s say I want to greet a user by name:
$UserName = "John Doe"
Write-Host "Welcome, $UserName!"In this case, Write-Host will display “Welcome, John Doe!” directly on the console. This output is not captured or stored; it’s purely for the user’s benefit.
Here is the exact output in the screenshot below:

Here is an example of using Write-Host:
$UserName = "Jane Smith"
Write-Host "Hello, $UserName! Welcome to the PowerShell tutorial."This will display: Hello, Jane Smith! Welcome to the PowerShell tutorial. directly on the console.
Check out PowerShell: Where-Object vs Select-Object
What is Write-Output in PowerShell?
On the other hand, Write-Output PowerShell cmdlet sends data to the output stream, making it available for further processing. This cmdlet is essential for passing data between different parts of a script or function.
Unlike Write-Host, the output from Write-Output can be assigned to variables, piped to other cmdlets, or redirected to files.
Consider the following example where we generate a list of cities:
$Cities = "New York", "Los Angeles", "Chicago"
Write-Output $CitiesHere, Write-Output sends the list of cities to the output stream. This data can be captured in a variable or piped to another cmdlet for further processing, such as sorting:
$Cities = "New York", "Los Angeles", "Chicago"
$SortedCities = Write-Output $Cities | Sort-ObjectHere is the output in the screenshot below:

Here is another example of using Write-Output in PowerShell.
$States = "California", "Texas", "Florida"
$OutputStates = Write-Output $States
$OutputStates | ForEach-Object { Write-Host "Processing state: $_" }This script sends the list of states to the output stream and then processes each state, displaying a message for each one.
Check out PowerShell ForEach-Object vs ForEach
PowerShell Write-Host vs Write-Output : Key Differences
To summarize, the key differences between Write-Host and Write-Output in PowerShell are:
- Purpose:
Write-Hostis for displaying messages directly to the console, whileWrite-Outputis for sending data to the output stream. - Usage: Use
Write-Hostfor user prompts and messages that don’t need further processing. UseWrite-Outputfor data that needs to be captured, piped, or processed further. - Output Handling:
Write-Hostdoes not send data to the pipeline, whereasWrite-Outputdoes.
Here is the summary in tabular format.
| Feature | Write-Host | Write-Output |
|---|---|---|
| Primary Purpose | Display messages directly to the console | Send data to the output stream |
| Usage Scenario | User prompts, informational messages | Data processing, passing data between cmdlets |
| Output Handling | No pipeline output | Sends data to the pipeline |
| Example Use Case | Write-Host "Hello, John!" | $Data = Write-Output "New York", "Los Angeles" |
Conclusion
I hope now you understand when to use Write-Host versus Write-Output in PowerShell. In this tutorial, I explained the difference between PowerShell Write-Host vs Write-Output with examples.
You may also like:
- PowerShell Where-Object vs Filter
- Set Execution Policy in PowerShell
- How to Wait for a Command to Finish in PowerShell?
- PowerShell Write-Host vs Write-Error
- PowerShell Write-Host vs Write-Information
Bijay Kumar is an esteemed author and the mind behind PowerShellFAQs.com, where he shares his extensive knowledge and expertise in PowerShell, with a particular focus on SharePoint projects. Recognized for his contributions to the tech community, Bijay has been honored with the prestigious Microsoft MVP award. With over 15 years of experience in the software industry, he has a rich professional background, having worked with industry giants such as HP and TCS. His insights and guidance have made him a respected figure in the world of software development and administration. Read more.