Understanding how PowerShell script exit codes are processed
Posted: (EET/GMT+2)
Working with PowerShell gives you great benefits in both system administration and automation, but also in software development. I've recently started automating most of the mundane development tasks with PowerShell, and this often requires working with external scripts and utilities, that might not know anything about PowerShell.
When you run an external script or utility from PowerShell, you often have nothing else to check than the process' exit code. In regular CMD.exe this used to be quite straightforward, but I've noticed that PowerShell is more complicated.
In PowerShell, you might also want to learn how to return exit codes from your own scripts. This allows building what I call building blocks, and allows you to build a collection of scripts that work together. The above exit code blog post on ASP.NET pages details how to do this.
Happy scripting!