PowerShell Studio Debugger Not Working

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 4 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
kdwisdom
Posts: 25
Last visit: Fri Jan 26, 2024 10:39 am

PowerShell Studio Debugger Not Working

Post 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
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: PowerShell Studio Debugger Not Working

Post 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.
Alexander Riedel
SAPIEN Technologies, Inc.
kdwisdom
Posts: 25
Last visit: Fri Jan 26, 2024 10:39 am

Re: PowerShell Studio Debugger Not Working

Post by kdwisdom »

Tools output:
  1. [System.Windows.Forms.DataGridViewSelectedCellCollection] CheckGroupOwnership_datagridview1 = {}
  2.     [System.Windows.Forms.DataGridViewCell] Item = null
  3.     [System.Int32] Count = 1
  4.     [System.Boolean] IsReadOnly = False
  5.     [System.Boolean] IsSynchronized = False
  6. CheckGroupOwnership_datagridview1_SelectedObjects = null
  7. [System.String] CheckGroupOwnership_displayName = lastname, firstname #changed this from what I actually searched for here as it had a real name
  8. [System.Int32] ExitCode = 0
  9. [DebuggerNameSpace.HostInvocationInfo] HostInvocation = {}
  10.     [System.Int64] HistoryId = 0
  11.     [System.String] InvocationName = ./My Program.Run.ps1
  12.     [System.String] Line = ./My Program.Run.ps1
  13.     [DebuggerNameSpace.HostCommandInfo] MyCommand = C:\Users\myuser\Documents\SAPIEN\PowerShell Studio\Projects\myprogram\myprogram.Run.ps1
  14.     [System.Int32] OffsetInLine = -2147483648
  15.     [System.Int32] PipelineLength = 1
  16.     [System.Int32] PipelinePosition = 1
  17.     [System.String] PositionMessage =
  18.     [System.Int32] ScriptLineNumber = 1
  19.     [System.String] ScriptName = C:\Users\myuser\Documents\SAPIEN\PowerShell Studio\Projects\myprogram\myprogram.Run.ps1
  20. [System.Windows.Forms.DataGridViewSelectedCellCollection] MainForm_datagridview1 = {}
  21.     [System.Windows.Forms.DataGridViewCell] Item = null
  22.     [System.Int32] Count = 0
  23.     [System.Boolean] IsReadOnly = False
  24.     [System.Boolean] IsSynchronized = False
  25. [System.Management.Automation.PSCustomObject] MainForm_datagridview1_SelectedObjects =
  26. [System.String] MainForm_displayName =
  27. [System.String] MainForm_secName =
  28. [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 4656 times
Here is the code:
  1. $buttonGetGroupsOwned_Click={
  2.     #TODO: Place custom script here
  3.    
  4.     $datagridview1.Rows.Clear()
  5.     $datagridview1.Columns.Clear()
  6.     $name = $displayName.Text
  7.     $wildcard = "*$name*"
  8.     $distinguishedName = Get-ADUser -Filter { name -like $wildcard } | select -ExpandProperty DistinguishedName
  9.    
  10.     $groups = get-adgroup -LDAPFilter "(ManagedBy=$distinguishedName)" | select -ExpandProperty name
  11.     $datagridview1.Columns.Add('sg', 'Security Group')
  12.     foreach ($group in $groups)
  13.     {
  14.  
  15.        
  16.             $datagridview1.Rows.Add($group)
  17.        
  18.     }
  19.     Set-Clipboard $groups
  20.     $Message = "Groups Owned By User are in Table Below and Copied to the Clipboard"
  21.     Show-Message $Message
  22. }
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: PowerShell Studio Debugger Not Working

Post 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.
Alexander Riedel
SAPIEN Technologies, Inc.
kdwisdom
Posts: 25
Last visit: Fri Jan 26, 2024 10:39 am

Re: PowerShell Studio Debugger Not Working

Post 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.
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: PowerShell Studio Debugger Not Working

Post 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?
Alexander Riedel
SAPIEN Technologies, Inc.
kdwisdom
Posts: 25
Last visit: Fri Jan 26, 2024 10:39 am

Re: PowerShell Studio Debugger Not Working

Post by kdwisdom »

I put a break point right at $MainForm_Load={ and it opened right up, no stopping at the break point.
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: PowerShell Studio Debugger Not Working

Post 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
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
Olga_B
Site Admin
Posts: 196
Last visit: Thu Mar 28, 2024 8:34 am

Re: PowerShell Studio Debugger Not Working

Post 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 196 times
kdwisdom
Posts: 25
Last visit: Fri Jan 26, 2024 10:39 am

Re: PowerShell Studio Debugger Not Working

Post 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?
This topic is 4 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.