Debugging Modules in PowerShell Studio
- Written by David Corrales
- Last Updated: 22 April 2016
- Created: 22 October 2012
- Hits: 2850
PowerShell Studio makes it easier to debug and run your module projects. You have the ability to execute and debug a module project directly from the IDE (Supported in PowerShell Studio v3.1.9 and up).
Debugging a module project:
When debugging (F4) or running (Ctrl + F4) a module project for the first time you will be asked to select a Startup Script:
This Startup Script will be used by PowerShell Studio as an entry point to run or debug the module project. Therefore, it’s important that you explicitly import the module in the script:
The Startup Script will be stored by the module project so you don’t have to select the script every time you wish to test the module. In addition, you have the option to change the Startup Script in the project’s properties.
To change the Startup Script, follow these simple steps:
- Select the project node in the Project Panel:
- Go to the Property Panel and edit the Startup Script property:
When debugging a module project, PowerShell Studio will build and export the module then execute the Startup Script. Any trace points and break points contained within the project files will be triggered by the debugger and mapped to the appropriate files:
Debugging a module without a project:
If you need to debug a module that doesn’t have a project, you can utilize PowerShell Studio’s new “Debug with Multiple Files” option.
First open the test script and the module files using PowerShell Studio. Next, debug the test script using the “Debug with Multiple Files” option and select the module files that you wish to debug.
Now the debugger will respond to break points located in the module files:
As you can see, these features help facilitate the module creation process for any user.