How do I debug a Windows PowerShell module in Visual Studio? How do I debug a Windows PowerShell module in Visual Studio? powershell powershell

How do I debug a Windows PowerShell module in Visual Studio?


It's possible to debug your cmdlet directly without needing a separate project. Open the properties of your class library project and configure the Debug tab as follows (assuming Windows is installed to C:):

  • Start Action
    • Start external program: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
  • Start Options
    • Command line arguments: -NoLogo -Command "Import-Module '.\MyModule.dll'; Get-TestCommand;"

Class library project configuration for PowerShell debugging

Debugging a PowerShell cmdlet


Edit: try this link or this step-by-step

Either downdload PowerShell Tools for Visual Studio 2015or use Windows PowerShell ISE.

How to Debug Scripts in Windows PowerShell ISE

Updated: October 17, 2013 Applies To: Windows PowerShell 2.0, Windows PowerShell 3.0, Windows PowerShell 4.0, Windows PowerShell 5.0 This topic describes how to debug scripts on a local computer by using the Windows PowerShell® Integrated Scripting Environment (ISE) visual debugging features. How to manage breakpoints How to manage a debugging session How to step over, step into, and step out while debugging How to display the values of variables while debugging
How to manage breakpoints A breakpoint is a designated spot in a script where you would like operation to pause so that you can examine the current state of the variables and the environment in which your script is running. Once your script is paused by a breakpoint, you can run commands in the Console Pane to examine the state of your script. You can output variables or run other commands. You can even modify the value of any variables that are visible to the context of the currently running script. After you have examined what you want to see, you can resume operation of the script. You can set three types of breakpoints in the Windows PowerShell debugging environment: Line breakpoint. The script pauses when the designated line is reached during the operation of the script...