Quick Links
Any script development usually requires troubleshooting which usually results in one of two approaches.
Built-in to PowerShell ISE and to Visual Studio Code is the ability to perform debugging.
How does PowerShell Debugging Work?
Included with Windows PowerShell, the PowerShell ISE has been the traditional go-to environment to debug PowerShell scripts.
With a built-in menu for debugging and a graphical representation of breakpoints, it is easy to get started.
First, any script that you are debugging must be saved.
Next, you will need to set breakpoints using one of three ways.
There are a few caveats to this.
,
, and
will not work as they are automatic variables and not subject to debugging.
Unlike the ISE, VS Code offers a much better and more useful debugging experience.
Also, you are not required to save before running!
ThePowerShell extension of VS Codeis required for this to work easily.
There are a few built-in commands to make this easy.
Check out how you could get started with PowerShell Debugging today!