Today, at a PowerShell discussion, someone asked about the difference between PowerShell Write-Host Vs Write-Information. PowerShell developers need to know about it. In this tutorial, I will explain the details.
PowerShell Write-Host
Write-Host is mainly used to display messages directly to the console. It is ideal for showing output that is meant for the user to read, such as status messages or prompts.
However, it’s important to note that Write-Host does not send output to the pipeline, which means the data it outputs cannot be used by other cmdlets.
Syntax
Here is the syntax of Write-Host.
Write-Host [-Object] <Object> [-NoNewline] [-Separator <Object>] [-ForegroundColor <ConsoleColor>] [-BackgroundColor <ConsoleColor>] [<CommonParameters>]Example
Let me show you an example to help you understand better.
Suppose you want to check the status of servers in different states. We want to display a message indicating the server’s status.
$servers = @("California-Server1", "Texas-Server2", "NewYork-Server3")
foreach ($server in $servers) {
# Simulate checking server status
$status = "Online"
Write-Host "$server is $status" -ForegroundColor Green
}In this example, Write-Host is used to display the server status in green text directly to the console.
Here is the exact output in the screenshot below:

Check out PowerShell Write-Host vs Write-Error
PowerShell Write-Information
Write-Information was introduced in PowerShell 5.0 and is used to write informational messages to the information stream. This cmdlet allows you to specify how PowerShell handles information stream data for a command, making it more useful than Write-Host. The information stream can be redirected or suppressed, which provides more control over the output.
Syntax
Here is the syntax of Write-Information.
Write-Information [-MessageData] <Object> [-Tags <Object[]>] [-NoNewline] [-InformationAction <ActionPreference>] [-InformationVariable <String>] [<CommonParameters>]Example
Continuing with our server status script, let’s use Write-Information to log the status messages.
$servers = @("California-Server1", "Texas-Server2", "NewYork-Server3")
foreach ($server in $servers) {
# Simulate checking server status
$status = "Online"
Write-Information "$server is $status"
}In this example, Write-Information logs the server status to the information stream, which can be redirected or handled differently based on the script’s needs.
Read PowerShell Write-Host vs Echo
Key Differences Between Write-Host and Write-Information
Here are the key differences between Write-Host and Write-Information in PowerShell.
| Feature | Write-Host | Write-Information |
|---|---|---|
| Output Destination | Directly to the console | Information stream |
| Pipeline Interaction | Does not send output to the pipeline | Sends output to the information stream, which can be redirected or suppressed |
| Customization | Supports text color customization with -ForegroundColor and -BackgroundColor parameters | Supports tagging with -Tags parameter and handling with -InformationAction and -InformationVariable parameters |
| Use Case | Best for displaying messages to the user directly | Best for logging informational messages that might need to be redirected or handled programmatically |
Conclusion
In this tutorial, I explained the difference between Write-Host and Write-Information in PowerShell. You must know now when to use Write-Host and when to use Write-Information.
You may also like:
- PowerShell: Where-Object vs Select-Object
- PowerShell ForEach-Object vs ForEach
- PowerShell Write-Host vs Write-Output
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.