---
title: "PowerShell Write-Host: Do You Still Need It?"
description: "Explore the popular PowerShell Write-Host cmdlet and determine if it's still necessary for your scripting needs."
canonical: "https://adamtheautomator.com/powershell-write-host/"
---

# PowerShell Write-Host: Do You Still Need It?

> Explore the popular PowerShell Write-Host cmdlet and determine if it's still necessary for your scripting needs.

Source: https://adamtheautomator.com/powershell-write-host/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![PowerShell Write-Host: Do You Still Need It?](https://adamtheautomator.com/wp-content/uploads/2020/11/PowerShell-Write-Host.png)

# PowerShell Write-Host: Do You Still Need It?

[![](https://secure.gravatar.com/avatar/f08b754bc0dce1c76685f6afa93185ecfb6f861fd14f993286e06bba69eaeb8b?s=192&d=mm&r=g)Adam Listek](https://adamtheautomator.com/author/alistek/)19 November 20203 min. read

Categories: [IT Ops](/category/it-ops/)

Tags:[PowerShell](/tag/powershell/)

Table of Contents

*   [Modern Use of PowerShell Write-Host](#h-modern-use-of-write-host)
*   [Formatting Messages for Readability](#h-formatting-messages-for-readability)
*   [Redirecting Write-Host Stream Output](#h-redirecting-write-host-stream-output)
*   [Conclusion](#h-conclusion)

Over the years, there has been a lot of debate around the PowerShell `Write-Host` cmdlet on whether you need to use it. As in most cases, the answer is maybe and dependent on your needs.

Not a reader? Watch this related video tutorial!

**_Not seeing the video? Make sure your ad blocker is disabled._**

To understand `Write-Host` and when to use it, let’s quickly explore the history of `Write-Host` and learn how best to use this useful cmdlet.

## Modern Use of PowerShell Write-Host

Often in a script or [PowerShell function](https://adamtheautomator.com/powershell-functions/ "PowerShell function"), you need to convert information to a user about what is happening that is informational and does not directly relate to the output of a function.

> _Why do we say the modern use of `Write-Host`? Prior to PowerShell 5.x, `Write-Host` was not tied to stream (such as the success, error, or warning streams). Therefore it was discouraged in use since it was not as controllable as the other output types._

Let’s take this simple example of a script that gives the user some information about how long a script is going to take to process.

```powershell
Write-Host "Starting the gathering of information, be patient, this could take a while!"
Write-Host "- Gathering Process`r`n- Gathering Files`r`n- Gathering Users"
Write-Output "Display the information here..."
Write-Host "Information Gathering Complete!"
```

![Displaying informational messages to the user.](https://adamtheautomator.com/wp-content/uploads/2020/11/Untitled-2020-11-17T142617.535.png)

Displaying informational messages to the user.

You’ll notice that this simply outputs information to the host which the end-user of your script can utilize to make further decisions. You may find yourself asking about pipeline content.

If you are sending objects from one cmdlet or function to another, but still want to display informational messages, can you do that? Thankfully, PowerShell’s `Write-Host` cmdlet does not affect pipeline output! Let’s show how that works below.

```powershell
Function Get-Information {
  Write-Host "Starting the gathering of information, be patient, this could take a while!`r`n"
  Write-Host "- Gathering Data`r`n- Returning Data`r`n"

  [PSCustomObject]@{
    "Test1" = "Value1"
    "Test2" = "Value2"
  }

  Write-Host "Information Gathering Complete!"
}

Function Convert-Information {
  Param(
    [Parameter(ValueFromPipeline=$true)]$Param
  )

  $Param | ConvertTo-JSON
}
```

If you pipe the output of `Get-Information` to `Convert-Information`, it will not take into account any of the statements and only operate on the `PSCustomObject` that is output.

![Demonstrate that pipelined output is not affected by Write-Host statements.](https://adamtheautomator.com/wp-content/uploads/2020/11/Untitled-2020-11-17T142641.401.png)

Demonstrate that pipelined output is not affected by `Write-Host` statements.

### Formatting Messages for Readability

Another very useful aspect of `Write-Host` is the ability to format colors and output. Since this can be used for easier readability, this can greatly help PowerShell script users to understand what is happening and when actions may need to be taken.

*   `-ForegroundColor` – The color of the information text.
*   `-BackgroundColor` – The color of the background behind the text.
*   `-Separator` – For objects that are output `Write-Host` use the supplied separator instead of a space. This can be a carriage return and newline character such as `"`r`n"`.
*   `-NoNewLine` – Don’t output a newline character at the end of the output.

Let’s explore how we can construct a useful information message leveraging the various formatting parameters. In the below code, we are constructing an informational message about the number of results for an array and applying formatting to make it easier to view.

> _Multiple objects can be passed in to `Write-Host` to display as seen below. Typically a scripter will separate these messages by a space, but with the separator parameter, you can control how these are output to the console._

```powershell
$Array = @(1,2,3,4,5)

Write-Host "Results Count:" -BackgroundColor DarkBlue -ForegroundColor White -NoNewline
Write-Host "" $Array.Count "Items`r`n" -ForegroundColor Red
Write-Host $Array -Separator "`r`n"
Write-Host "" "End of results." -ForegroundColor Green -Separator "`r`n"
```

![End of Results](https://adamtheautomator.com/wp-content/uploads/2020/11/Untitled-2020-11-17T142739.867.png)

End of Results

By controlling the output with colors, newline, and separator output, we can craft a useful message that will give information about the script to the user. An example of this scenario is when you [create an informational menu](https://adamtheautomator.com/powershell-menu/), among other use cases.

### Redirecting `Write-Host` Stream Output

Since `Write-Host` is now controllable by stream output, there are a few ways to control and redirect the output. The `InformationAction` preference is partly taken into account with `Write-Host` messages. `-InformationAction Ignore` will effectively suppress `Write-Host` messages, but the `$InformationPreference` and `InformationAction` parameter does not affect the `Write-Host` cmdlet.

> _Did you know that `Write-Host` is just a wrapper around the `Write-Information` cmdlet? This enables the output of `Write-Host` to be contained within the information stream. This means that you can modify where `Write-Host` messages go using the information stream._

That being said, you can still redirect the output of the `Write-Host` messages to a different stream using the redirection operators. For example, output all `Write-Host` messages to a log file. Taking that same example as seen above, let’s redirect all that output to a log file.

```powershell
Write-Host "Results Count:" -BackgroundColor DarkBlue -ForegroundColor White -NoNewline 6>> .\log.txt
Write-Host "" $Array.Count "Items`r`n" -ForegroundColor Red 6>> .\log.txt
Write-Host $Array -Separator "`r`n" 6>> .\log.txt
Write-Host "" "End of results." -ForegroundColor Green -Separator "`r`n" 6>> .\log.txt
```

![Redirected output to a log file.](https://adamtheautomator.com/wp-content/uploads/2020/11/Untitled-2020-11-17T142819.380.png)

Redirected output to a log file.

As you can see, PowerShell now redirects the output to a log but the formatting may not be exactly what you intended. That’s because the `-NoNewLine` parameter isn’t really respected since that is mostly a host formatting tool. This may not be a big deal, but something to keep in mind when redirecting the stream output.

## Conclusion

With the changes in [PowerShell 5.x](https://4sysops.com/wiki/differences-between-powershell-versions/) and on, `Write-Host` is perfectly allowed for use and encouraged when you need to display informational messages to the user. Since a PowerShell user will have the necessary level of control over an informational message the same as an output or verbose message, the use of `Write-Host` or `Write-Information` is encouraged and recommended for use as necessary.

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Fpowershell-write-host%2F&text=PowerShell%20Write-Host%3A%20Do%20You%20Still%20Need%20It%3F)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Fpowershell-write-host%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Fpowershell-write-host%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2026/06/26995-troubleshoot-dns-issues-powershell-codex.webp)

### [Troubleshoot DNS Issues with PowerShell](/troubleshoot-dns-issues-powershell/)

Troubleshoot DNS issues with PowerShell by testing name resolution, DNS client settings, cache entries, and network connectivity in a repeatable workflow.

![](https://adamtheautomator.com/wp-content/uploads/2025/10/image_2025-10-24_095322075.png)

### [Migrating from PowerShell 6 to 7.5: Breaking Changes/New Features](/migrating-powershell-6-to-7-5/)

Migrate from PowerShell Core 6 to 7.5: breaking changes, features, and testing tips.

![](https://adamtheautomator.com/wp-content/uploads/2025/06/featured-image-6.png)

### [How to Add Timeouts to Pester Tests with PowerShell Runspaces](/pester-test-timeout-runspaces/)

Prevent Pester tests from hanging indefinitely using PowerShell runspaces. Learn to handle variable scoping, module loading, TestDrive access, and stream capture challenges with timeout protection.

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
