Vscode-powershell: Debugging psm1 file

Created on 21 Apr 2016  路  2Comments  路  Source: PowerShell/vscode-powershell

I am having an issue where i am attempting to debug a psm1 module script. When I launch the debugger with standard Powershell launch.json settings, I get an error "Cannot run a document in the middle of a pipeline: C:\samplemodule.psm1."
Any specific way i can invoke the "import-module .\samplemodule" somehow?

Most helpful comment

You can create a debug.ps1 file that imports the module and runs exported commands. Or you can create a Pester test (SampleModule.Tests.ps1) file that imports the module and tests the commands in that file. You can than run the debug.ps1 or Pester test file under the debugger.

All 2 comments

You can create a debug.ps1 file that imports the module and runs exported commands. Or you can create a Pester test (SampleModule.Tests.ps1) file that imports the module and tests the commands in that file. You can than run the debug.ps1 or Pester test file under the debugger.

Gotcha. Thank you.

Was this page helpful?
0 / 5 - 0 ratings