Powershell Errors

Shane O’Neill explains what the $error variable does:

Now ignoring the fact that you already know what is wrong, this tells me that there is either something wrong with the $Database variable, the $sql variable or the syntax statement. Maybe even something else though!
This is not helpful and I’m going to have a bad time.

I encountered this lately and thanks to Chrissy LeMaire ( b | t ), I was introduced to the $error variable.

Shane also has an interesting side note around error colors.

Related Posts

String Formatting With Powershell

Thomas Raynor provides a quick tip for string formatting in Powershell: And, for some reason, instead of the default output which is formatted like a table, I want output presented like this. 1 2 3 .ps1     file extension: 11 .xlsx    file extension: 3 .dll     file extension: 1 This is a silly example, but notice that even […]

Read More

What’s In Your Powershell Profile?

Shane O’Neill wants to know what’s in your Powershell profile: This brings me back to the main point. My profile does 3 things Changes the default colour of error and warning messages, Sets an alias for notepad to “n” since I use it so much Set-Alias -Name n -Value notepad , and loads up the dbatools prompt […]

Read More


March 2017
« Feb Apr »