Posts Tagged ‘Debugging’


PowerShell GUI Debugging Tip: Duplicate Event Handlers

Tuesday, September 8th, 2015 by June Blender
I'm not a professional tester, but I am an expert at making mistakes. I take risks. I try everything. I gravitate to "corner cases" and odd circumstances. That makes me a great amateur tester and, due to a lifetime of experience with breaking things, a pretty good debugger. But, at the Omaha PowerShell User Group meeting in August 2015, I was stumped. What caused this bug? David Jones, an Omaha PSUG member and talented PowerSheller, showed me the following code. $FormGetService_Load = { $textboxComputerName.Text = $env:ComputerName } Looks perfect. But when he ran his script, on load, the $TextboxComputerName textbox was empty.  …   More »

PowerShell Studio 2015: Enhancements for Debugging

Monday, July 13th, 2015 by David Corrales
In the last service release v4.2.86 we introduced some new enhancements to help improve your debugging experience.   New Variables Panel Context Menu We added a new context menu to the Variables Panel that allows you to: Add To Watch – Adds the selected variable to the Watch Panel. Query in Debug Console – Runs the variable in the Debug Console, so that you can inspect the variable. If you select a property, then the variable’s property will be queried in the Debug Console. Copy – Copies the cell contents to the clipboard. New Watch Panel Context Menu We also…   More »

Debugging Modules in PowerShell Studio 2012

Monday, October 22nd, 2012 by David Corrales
PowerShell Studio now makes it easier to debug and run your module projects. You now have the ability to execute and debug a module project directly from the IDE (Supported in PowerShell Studio 2012 v3.1.9 and up). Debugging a module project: When debugging (F4) or running (Ctrl + F4) a module project for the first time you will be asked to select a Startup Script:   This Startup Script will be used by PowerShell Studio as an entry point to run or debug the module project. Therefore, it’s important that you explicitly import the module in the script: The Startup…   More »

Debugging multiple scripts with PrimalScript 2012

Thursday, October 11th, 2012 by Alex Riedel
Debugging a simple script with a few lines is not a big deal, hit debug and step through it. Almost any PowerShell related editor can do that today. But what if you need to debug a complete system of scripts interacting with one another? This new service build of PrimalScript 2012 introduces the ability to debug multiple scripts. Sure you could type Set-PSBreakPoint –script filename.ps1 –line xxx as needed and launch the whole thing from the command line, but let’s face it, if you do that more than twice it gets a bit old. PrimalScript already saves your breakpoints with…   More »

Debugging PowerShell on Windows 8

Tuesday, September 20th, 2011 by Alex Riedel
Yes you can! Just make sure you run PowerShell ONCE before installing PrimalScript. Some of the PowerShell assemblies are not available in the GAC before it runs at least once.…   More »

Fun with Debug Messages

Wednesday, July 23rd, 2008 by Jeffery Hicks
In my script and function development, I often add the line $DebugPreference="SilentlyContinue" to the beginning of my code. Throughout the script I add lines using Write-Debug that tell me what the script is doing or the value of a particular variable. This has been very helpful. When I want to see the debug messages, I set $DebugPreference to "Continue" and voila!. In PrimalScript all the messages are written to the debug panel. But I wanted more .   More »

PowerShell and the Heisenberg Principle

Monday, July 7th, 2008 by Alex Riedel
While developing the PowerShell debugger for PrimalScript 2007 we tested with a large number of scripts. Pretty much anything we could lay our hands on. The following script was one of them. function AreArraysEqual($a1, $a2) {     $enum1 = $a1.GetEnumerator()     $enum2 = $a2.GetEnumerator()        #"$enum1"     while ($enum1.MoveNext() -and $enum2.MoveNext()) {       if ($enum1.Current -ne $enum2.Current) {             return $false       }     }     return $true } $a1 = @(1, 2, 3, 5) $a2 = @(3, 1, 2, 4) AreArraysEqual $a1 $a2   Please note that the code is simplified and error checks are removed for that purpose.…   More »