Page 1 of 1

PS2011 No Private Variable Debug

Posted: Thu Nov 03, 2011 2:41 pm
by peter_mclean@dodo.com.au
PS 2011 V6.0.154 XP Profession SP3
When debugging a Powershell script in the Primalscript Editor/Debugger, variables that are defined as private in a function, show empty results in the Watch Window and do not appear at all in the Variables Window. Please refer to the 1st snapshot noting that $gca_CrackerUserArray that is not scoped as private appears in the Variables Window, whereas $gca_CrackerUser that is scoped as private, does not. Also please note that the Result in the Watch Window for $gca_CrackerUser is (Empty).
Also please note on the 2nd snapshot that the $gca_CrackerUserArray has a result in the Watch Window. Also please note that Primalscript crashed shortly after i took the 2nd snapshot, with an out of memory error.
NoPrivateVariableDebug.jpg
NoPrivateVariableDebug1.jpgpmclean@labelmakers.com.au2011-11-03 21:49:09

PS2011 No Private Variable Debug

Posted: Thu Nov 03, 2011 7:56 pm
by Alexander Riedel
I will look into it.

As for the crash, where you able to save any of the crash data?

PS2011 No Private Variable Debug

Posted: Wed Nov 09, 2011 7:51 am
by peter_mclean@dodo.com.au
Have just installed PS 2011 V6.0.155. I have not had any problems with out of memory, but the private variable values are still not available. Here are the snapshots from the debugger showing 1) test script 2) intended output for script 3) watch on not-private variable 4) watch on private variable.

TestDebugPrivateVariablesScript.jpg
TestDebugPrivateVariablesScriptOutput.jpg
TestDebugPrivateVariables1.jpg
TestDebugPrivateVariables2.jpg

PS2011 No Private Variable Debug

Posted: Wed Nov 09, 2011 8:59 am
by Alexander Riedel
PowerShell's debugging interface has no means whatsoever to determine the content of private variables or even check for their existence. I have forwarded you complaint to Microsoft, hoping that some day they may add a way to query for those.

PS2011 No Private Variable Debug

Posted: Wed Nov 09, 2011 9:10 am
by peter_mclean@dodo.com.au
Thanks Alex for your very valued input. I now undertand why. I suppose I'll just have to use the Microsoft Powershell ISE or the PowerGUI Script Editor when I need to debug private variables.

PS2011 No Private Variable Debug

Posted: Wed Nov 09, 2011 9:13 am
by Alexander Riedel
I knew you would say that :-)
I am sure there is a hack, but we tend to stick with the official API.