Powershell Error Handling

Writing powershell scripts often; If yes, I believe that you have to be checking for errors for every command.

A quick way that I use if to check the variable $error. I get the value $error.Count before a command and then compare that value to the value after the command. If it's increased, something went wrong.

You may also want to get the error that occurred. Good news, you can use the variable $error[0].

For any other stuff, take a look at the other members and properties of the $error variable..

Popular posts from this blog

Domain Controller Machine Password Reset

Configuring a Certificate on Exchange Receive Connector

Running Multiple NGINX Ingress Controllers in AKS