开发者

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 ru开发者_如何学Pythonnned:

powershell -command "& {get-content %1 | .\Install.ps1}"

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:

install.cmd dev.txt

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜