
Once a breakpoint is set the line of code will turn a dark brown color. The two most common ways to set a breakpoint are by moving the cursor to the line we want to break in and press the F9 key or by clicking on the grey area to the left. The most commonly used method for entering break state is by setting a breakpoint in our code. The advantage of the code being in a break state is that we get access to what is called the state of the application which is composed of functions, variables and objects present in memory at the time the application entered the break state. In the break state, the execution is stopped either by an exception or the execution hit a breakpoint we specified inside the code. It will either be running or in a break state. When we are debugging an application in Visual Studio, our code will be in two states. Now when we start to debug, it will launch PowerShell with the command arguments specified allowing us to debug the module. You will notice that, since this is an XML file, we represented the ampersand character differently so as to follow proper XML formatting. In our example, it would be to start debugging with a target of An圜PU and specify what program to start and the arguments it should process. We create a property group with the condition that would trigger the action.

In the case of our module the option would be: -noexit -command "&" So, there is no need to specify the full path. The debugger starts always in the default location where the DLL is generated. In the Start Options -> Command Line Arguments textbox, enter the parameters for the PowerShell executable that will automatically load the module once it is compiled. Navigate to PowerShell.exe for the architecture of your project. In the properties window, select Debug tab and select Start external program under Start Options.

We start by going to the project properties by right-clicking on the project name inside the Solution Explorer pane or pressing Alt + Enter.

This feature allows us to launch PowerShell with the arguments to load the built module so that we can start debugging it. The commercial versions of Visual Studio allow us to call an external program and pass parameters to it. Setting Up Debugging in Visual Studio 2013 (Ultimate, Premium, and Professional) Depending on the version of Visual Studio, this can be setup automatically or manually. In the case of PowerShell, we need to load the library in a PowerShell process to be able to debug it. Typically when developing a library inside of Visual Studio, one would link the library to a main project and the project would in turn load the library to allow us to debug the code and be able to control the execution. In addition to the two classes that inherit from the PSCmdlet class, there is another class called IPTool that is used for turning an IP Address to an integer and for getting the hosts count for a specified network range.

