Use the other Write- cmdlets

One of the unsung features of PowerShell are the many ways to provide output.  For completely automated script via Scheduled Task or Orchestrator, I go straight to the Event Log now. 

But for the majority of scripts you’ll run on the command line, there is a lot more than Write-Output.  By the way, Don Jones says God kills a puppy each time you use Write-Host, so don’t do that.


Excellent for trace level information and you can enable/disable with –Debug and $DebugPreference.


· Step by step information like “Now running trash compactor…”, switched with –Verbose and $VerbosePreference.


Show of hands, who actually knew this was there?  Now you do.  Switched with –WarningAction and $WarningPreference.


Looks just like a regular paragraph long red error message, switched with –ErrorAction and $ErrorPreference.

I’m moving all inline comments to Write actions and making decisions about the right level of notice along the way.  I definitely like the ability to control output when running scripts now.

This entry was posted in PowerShell. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s