locked
Debug Prompt not coming when Powershel breakpoint hit RRS feed

  • Question

  • Hi,

    I have created a breakpoint as follows

    Set-PSBreakpoint -Command get-process -Script C:\Temp\SP\AutoSPInstaller\AutoSPInstallerFunctions.ps1

    or

    Set-PSBreakpoint -Script C:\Temp\SP\AutoSPInstaller\AutoSPInstallerFunctions.ps1 -line 2132

    Then I launch a batch file which internally calls PowerShell script  AutoSPInstallerFunctions.ps1

    C:\Temp\SP\AutoSPInstaller\AutoSPInstallerLaunch.bat

    When the breakpoint hits DBG prompt does not show up it only shows me breakpoint hit it never provides me an option of step into, list ,step-over etc...

    Any clue!! 


    Wednesday, June 1, 2016 2:15 AM

Answers

  • How do I change this line so that I setthe breakpoint

    "%SYSTEMROOT%\system32\windowspowershell\v1.0\powershell.exe" -Command Start-Process "$PSHOME\powershell.exe" -Verb RunAs -ArgumentList "'-NoExit -ExecutionPolicy Bypass %~dp0\AutoSPInstallerMain.ps1 %InputFile%'"

     

    Because this is how batchfile calling the powershell main which in turn calling functions file.

    Regards

    Rajaniesh

     

    You cannot set a breakpoint before you start  a process.

    To launch PowerShell and break in a called script you need to specify the path to the called scripts line or variable you need to break on.

    You cannot specify both a "-command" and a "-file" in the same run command.

    Perhaps you should redesign your launch process.  Why you would do this is not clear. It seems unnecessary.


    \_(ツ)_/

    • Proposed as answer by Elton_Ji Thursday, June 16, 2016 2:50 AM
    • Marked as answer by Elton_Ji Sunday, June 26, 2016 3:02 PM
    Friday, June 3, 2016 11:23 PM

All replies

  • Hi Sir,

    >>Then I launch a batch file which internally calls PowerShell script 

    As you mentioned , powershell.exe was called by CMD shell .

    But , set-psbreakpoint is stored in one PS process (based on my test).

    So , you may need to add "set-psbreakpoint" command when call Powershell.exe (in bat file )  :

    powershell.exe -command " Set-PSBreakpoint -Command get-process -Script C:\Temp\SP\AutoSPInstaller\AutoSPInstallerFunctions.ps1 ; C:\Temp\SP\AutoSPInstaller\AutoSPInstallerFunctions.ps1 "

     

    Best Regards,

    Elton


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com .


    • Edited by Elton_Ji Wednesday, June 1, 2016 10:27 AM
    • Proposed as answer by Elton_Ji Friday, June 3, 2016 9:21 AM
    Wednesday, June 1, 2016 10:27 AM
  • Hi Sir,

    Is there any update ?

    Best Regards,

    Elton


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com .

    Friday, June 3, 2016 9:21 AM
  • Why should someone want to start Powershell out of the console and get breakpoint informations? If you want a sencefull debugging, use the ISE. Here, you can run partial code with F8 to see what happens.
    Friday, June 3, 2016 12:59 PM
  • Thee console does debugging well. Neither the console nor the ISE can breakpoint into a different process.  YOU would need to use an advanced JIT debugger for that.

    \_(ツ)_/

    Friday, June 3, 2016 3:07 PM
  • Thank YOU Elton. I have a question here....How to set the breakpoint if AutoSPInstallerFunctions.PS1 Script is being called by AutoSPInstallerMain.PS1 and my Batch file calls  AutoSPInstallerMain.PS also is there any way to break before error is thrown ...Do we need to use any switch for that condition.

    Regards

    Rajaniesh

    Friday, June 3, 2016 9:26 PM
  • How do I change this line so that I setthe breakpoint

    "%SYSTEMROOT%\system32\windowspowershell\v1.0\powershell.exe" -Command Start-Process "$PSHOME\powershell.exe" -Verb RunAs -ArgumentList "'-NoExit -ExecutionPolicy Bypass %~dp0\AutoSPInstallerMain.ps1 %InputFile%'"

     

    Because this is how batchfile calling the powershell main which in turn calling functions file.

    Regards

    Rajaniesh

     

    Friday, June 3, 2016 9:36 PM
  • How do I change this line so that I setthe breakpoint

    "%SYSTEMROOT%\system32\windowspowershell\v1.0\powershell.exe" -Command Start-Process "$PSHOME\powershell.exe" -Verb RunAs -ArgumentList "'-NoExit -ExecutionPolicy Bypass %~dp0\AutoSPInstallerMain.ps1 %InputFile%'"

     

    Because this is how batchfile calling the powershell main which in turn calling functions file.

    Regards

    Rajaniesh

     

    You cannot set a breakpoint before you start  a process.

    To launch PowerShell and break in a called script you need to specify the path to the called scripts line or variable you need to break on.

    You cannot specify both a "-command" and a "-file" in the same run command.

    Perhaps you should redesign your launch process.  Why you would do this is not clear. It seems unnecessary.


    \_(ツ)_/

    • Proposed as answer by Elton_Ji Thursday, June 16, 2016 2:50 AM
    • Marked as answer by Elton_Ji Sunday, June 26, 2016 3:02 PM
    Friday, June 3, 2016 11:23 PM
  • This is a part of the code written by AutoSPInstaller team..i am trying to run it and debug it
    Tuesday, June 7, 2016 4:56 PM
  • This is a part of the code written by AutoSPInstaller team..i am trying to run it and debug it

    Then you should ask the installer team for help.


    \_(ツ)_/

    Tuesday, June 7, 2016 5:03 PM
  • there is no help coming from them and I thought to develop my debugging skills to get a workaround for this

    Can you help in finding a way out to debug this one.

    Tuesday, June 7, 2016 7:47 PM
  • I think you have the answer.  What you want to do cannot be done.

    You cannot debug across process with the PS debugger.


    \_(ツ)_/

    Tuesday, June 7, 2016 7:55 PM