Enter Debug Mode PowerShell Scripts

When you are using the custom scripts action items (either direct or import), you have the possibility to enter a debug mode anywhere in your script. This can be very useful when you want to see why exactly your script might be failing, and you can inspect the values of your variables in real time.

To enter the debugging mode from a custom script, put the following in your custom script:

$global:am_debug =$true

The run-time will enter the (PowerShell) debugging mode at that point.

Login AM Enter Debugging Mode From Custom PowerShell Scripts 01.png

Hint: To get a list of commands available during debugging mode, type ?

Note: Debugging mode will not be entered if you are working on a remote PowerShell session, because PowerShell remoting doesn't support debugging.