PowerShell Private Data
In an earlier article, we looked at the relationship between PowerShell and the hosting application. One aspect of this relationship determines how some things are formatted in PowerShell. When you run a Write-Verbose statement, it typically is displayed in yellow. When an error occurs, PowerShell displays it red. Or, more accurately, PowerShell tells the host, “display this using whatever setting you have for yellow.” Generally, we know what yellow and red should look like. But as we’ll look at later, this isn’t always obvious. In this article, I want to explore the world of private data and share some tools you can use to get the most out of it.
PrivateData
PowerShell maintains a set of color configurations for the different pipelines (a topic in itself for another day). You can manage these settings from $host.PrivateData
. Here’s what my Windows PowerShell session gives me.