Taking PowerShell in a New (Re)direction
Normally, when we run a PowerShell command or pipeline expression, we focus on the output. We’re manipulating objects in the pipeline until we get the desired result. Whatever is left in the pipeline is formatted and displayed on the screen. Of course, we can also redirect the output to different file formats such as CSV or JSON. Or, we can send output to a text file. But what if we include Verbose output? What about errors and warnings? How can we save that output to a file?
You’ve heard me say that PowerShell is an interactive management shell as much as it is a scripting language. Every shell I’ve ever used supports the concept of redirection. That is, redirecting an output stream to a file. PowerShell is no different. Today, I want to demonstrate how to redirect PowerShell streams and how you might leverage this feature in your PowerShell work.