Debug .ps1 file started from a dos command file


I want to run a Powershell script (.ps1) to deploy Biztalk2009 artifacts in a virtual machine.

The .ps1 file is running from a dos command file called ‘install.cmd’.

As part of the install.cmd file the Powershell is runned:

The 24 parameters needed for the script are stored in a .txt file and the filename is given as a parameter of the dos command file. The parameter file is just a regular .txt file. So I run the dos command file as:

Now I encounter several exceptions and I want to debug the Powershell script(s). The initial Powershell script uses a 2nd function Powershell script called ‘functions.ps1’.

The exceptions are arising from the 2nd script.

How can I easily debug the Powershell scripts that are started from a dos command ?


If you can modify Install.ps1, insert a Set-PSDebug -Step command near the beginning of the script or where you are interested in stepping through the script. Once you start stepping you can press “S” to enter a nested prompt and from there you can examine the value of variables variables (and modify their values) as well as execute commands.

If you are on PowerShell 2.0, you can also use Set-PSBreakpoint on a line in your script or the use of a command or the read/write of a variable.


Debug .ps1 file started from a dos command file by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply