Debug.ps1 file is run from dos command file

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

The .ps1 file is launched from the dos command file named 'install.cmd'.

As part of the install.cmd file, Powershell runs:

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

The 24 parameters necessary for the script are stored in the .txt file, and the file name is specified as the parameter of the dos command file. A parameter file is a regular .txt file. Therefore, I run the dos command file as:

 install.cmd dev.txt 

Now I have a few exceptions and I want to debug the Powershell script (s). The original Powershell script uses a second Powershell script function called "functions.ps1".

Exceptions arise from the 2nd script.

How can I easily debug Powershell scripts that run from the dos command?

+4
source share
1 answer

If you can change Install.ps1, insert the Set-PSDebug -Step near the start of the script or where you are interested in going through the script. After you start pacing, you can press "S" to enter a nested prompt, and from there you can check the value of variable variables (and change their values), as well as execute commands.

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

+3
source

Source: https://habr.com/ru/post/1344606/


All Articles