Page 1 of 1

PowerShell Studio Debugger Not Working

Posted: Tue Oct 22, 2019 11:10 am
by kdwisdom
To help you better we need some information from you.

*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***

Product: PowerShell Studio 2019 (64 Bit)
Build: v5.6.167
OS: Windows 10 Enterprise (64 Bit)
Build: v10.0.17134.0

*** Please add details and screenshots as needed below. ***

I have read a few posts about others having issue with the debugger but none of them had answers that were applicable to my situation.

My PS Studio is set to V5 - 64 bit. When I click to make a breakpoint next to code and then click "Debug" it doesn't stop at any break points anywhere in my code and just runs it.

This is making it very difficult to diagnose errors in any of my scripts/code because I can't read the output of any variables/errors in debugging.

Any help would be greatly appreciated, thanks!

Kyle

Re: PowerShell Studio Debugger Not Working

Posted: Tue Oct 22, 2019 11:48 am
by Alexander Riedel
There is an issue specific to V2 that we have recently been made aware of. The issue was introduced by recent changes in the PowerShell engine or in the .NET framework used. We have isolated and already fixed this issue. Just in case someone else is reading this :D

At any rate, this does not in any way affect PowerShell V5. That does not mean that there cannot be any changes that affect that, but your post does not include enough information to determine that.
At this moment we have no other report that breakpoints are affected in PowerShell V5.
I completely understand the difficulty and frustration you may experience. The fastest way would be to post a sample script you use, where it does not stop at a breakpoint. Please include the script (as an attachment) and add a screenshot where you placed the breakpoint.
Please also look at the "Tools output" tab after running your script and provide a screenshot of that as well.
We will try to reproduce that and see what other information we may need.

Re: PowerShell Studio Debugger Not Working

Posted: Wed Oct 23, 2019 8:03 am
by kdwisdom
Tools output:
  1. [System.Windows.Forms.DataGridViewSelectedCellCollection] CheckGroupOwnership_datagridview1 = {}
  2.  
  3.     [System.Windows.Forms.DataGridViewCell] Item = null
  4.  
  5.     [System.Int32] Count = 1
  6.  
  7.     [System.Boolean] IsReadOnly = False
  8.  
  9.     [System.Boolean] IsSynchronized = False
  10.  
  11. CheckGroupOwnership_datagridview1_SelectedObjects = null
  12.  
  13. [System.String] CheckGroupOwnership_displayName = lastname, firstname #changed this from what I actually searched for here as it had a real name
  14.  
  15. [System.Int32] ExitCode = 0
  16.  
  17. [DebuggerNameSpace.HostInvocationInfo] HostInvocation = {}
  18.  
  19.     [System.Int64] HistoryId = 0
  20.  
  21.     [System.String] InvocationName = ./My Program.Run.ps1
  22.  
  23.     [System.String] Line = ./My Program.Run.ps1
  24.  
  25.     [DebuggerNameSpace.HostCommandInfo] MyCommand = C:\Users\myuser\Documents\SAPIEN\PowerShell Studio\Projects\myprogram\myprogram.Run.ps1
  26.  
  27.     [System.Int32] OffsetInLine = -2147483648
  28.  
  29.     [System.Int32] PipelineLength = 1
  30.  
  31.     [System.Int32] PipelinePosition = 1
  32.  
  33.     [System.String] PositionMessage =
  34.  
  35.     [System.Int32] ScriptLineNumber = 1
  36.  
  37.     [System.String] ScriptName = C:\Users\myuser\Documents\SAPIEN\PowerShell Studio\Projects\myprogram\myprogram.Run.ps1
  38.  
  39. [System.Windows.Forms.DataGridViewSelectedCellCollection] MainForm_datagridview1 = {}
  40.  
  41.     [System.Windows.Forms.DataGridViewCell] Item = null
  42.  
  43.     [System.Int32] Count = 0
  44.  
  45.     [System.Boolean] IsReadOnly = False
  46.  
  47.     [System.Boolean] IsSynchronized = False
  48.  
  49. [System.Management.Automation.PSCustomObject] MainForm_datagridview1_SelectedObjects =
  50.  
  51. [System.String] MainForm_displayName =
  52.  
  53. [System.String] MainForm_secName =
  54.  
  55. [System.String] ScriptDirectory = C:\Users\myuser\Documents\SAPIEN\PowerShell Studio\Projects\myprogram
***** Post mortem variable output *****

Here is a screenshot of the code with the breakpoint:
codeview.jpg
codeview.jpg (90.38 KiB) Viewed 2095 times
Here is the code:
  1. $buttonGetGroupsOwned_Click={
  2.  
  3.     #TODO: Place custom script here
  4.  
  5.    
  6.  
  7.     $datagridview1.Rows.Clear()
  8.  
  9.     $datagridview1.Columns.Clear()
  10.  
  11.     $name = $displayName.Text
  12.  
  13.     $wildcard = "*$name*"
  14.  
  15.     $distinguishedName = Get-ADUser -Filter { name -like $wildcard } | select -ExpandProperty DistinguishedName
  16.  
  17.    
  18.  
  19.     $groups = get-adgroup -LDAPFilter "(ManagedBy=$distinguishedName)" | select -ExpandProperty name
  20.  
  21.     $datagridview1.Columns.Add('sg', 'Security Group')
  22.  
  23.     foreach ($group in $groups)
  24.  
  25.     {
  26.  
  27.  
  28.  
  29.        
  30.  
  31.             $datagridview1.Rows.Add($group)
  32.  
  33.        
  34.  
  35.     }
  36.  
  37.     Set-Clipboard $groups
  38.  
  39.     $Message = "Groups Owned By User are in Table Below and Copied to the Clipboard"
  40.  
  41.     Show-Message $Message
  42.  
  43. }

Re: PowerShell Studio Debugger Not Working

Posted: Wed Oct 23, 2019 8:29 am
by Alexander Riedel
Maybe there is a misunderstanding. What I asked for is a complete sample script that illustrates where you put a breakpoint and where it does not stop.
Not a fragment and not code we cannot run here because it relies on your environment.
If I paste your button handler into another form, clean out all code that is dependent on your environment and debug it, it stops right there as soon as I click the button.

But that is not the test I had in mind. Create a simple form, with one text box and a button, please a breakpoint in the button handler. See if that stops.
If not, sent the ENTIRE script you generated please.

Re: PowerShell Studio Debugger Not Working

Posted: Wed Oct 23, 2019 9:15 am
by kdwisdom
Ok, I created a brand new project with one form, button, and label, added a breakpoint on it, it works fine, but in my multi-form project, it's not working and I have a TON of forms in this multi-form project, so not sure where to start with it.

Re: PowerShell Studio Debugger Not Working

Posted: Wed Oct 23, 2019 9:21 am
by Alexander Riedel
Ok, an important first step. So breakpoints basically work in general.
Can you place a breakpoint at the entrance to your app, where the first form is shown, and see if it stops there?

Re: PowerShell Studio Debugger Not Working

Posted: Wed Oct 23, 2019 9:29 am
by kdwisdom
I put a break point right at $MainForm_Load={ and it opened right up, no stopping at the break point.

Re: PowerShell Studio Debugger Not Working

Posted: Wed Oct 23, 2019 9:33 am
by Alexander Riedel
I have handed this to QA to create a multi-form project and see what they can find out. Please stand by

Re: PowerShell Studio Debugger Not Working

Posted: Wed Oct 23, 2019 10:09 am
by Olga_B
Hello Kyle,
I tested debugging with simple multi-form project and Debug works fine with PowerShell V5.
Could you test attached project on your computer. Make sure the selected platform is V5
test-debug.zip
(38.73 KiB) Downloaded 64 times

Re: PowerShell Studio Debugger Not Working

Posted: Wed Oct 23, 2019 11:03 am
by kdwisdom
I went ahead and created a new project and moved my files over one by one and the debugger works fine in a new project with the same PSF files and the Globals file.

So it seems to be a problem with the overall project, any idea what could cause that?