variable hashtable property view

Use this forum to ask questions after your subscription maintenance expires or before you buy. Need information on licensing or pricing? Questions about a trial version? This is the right place for you. No scripting questions, please.
Forum rules
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.
Posts: 2
Joined: Tue Mar 03, 2020 2:21 pm

variable hashtable property view

Post by Drunkpenguin »

Hello everybody

Before trying out Powershell Studio 2020 I just worked with Powershell ISE. Now with ISE there’s one feature I very frequently used, but I’m probably gonna have to explain it for you to understand:

I use various self-written modules, which return hashtables. I use them as seen in the attachment "ISECase"

“getVMData” is the module, which returns the hashtable. So after I executed it, “$vmData” is a hashtable with various values in it. Now I don’t always know every single value and PropertyName, so I usually just type “$vmdata.” And then it lists me all the different possibilities. Of course only after I ran the first line with F8 in the console. (Also seen on the second line in "ISECase")

Now with Powershell Studio it shows certain options, on what to do but not the propertynames of the different values, which I could use: (for example $vmdata.upTime) It doesn't suggest the possibilities I need. (As Seen in PWStudio2020Case)

My Version is up to date as seen in "isUpToDate"

Is there some way I can display all the values or properties of the hashtable which I could use? It doesn’t have to be like it was in ISE, I just need some kind of list, from which I see, what values I should use for what.

Thanks in Advance and Best Regards
PWStudio2020Case.png (18.34 KiB) Viewed 18103 times
isUpToDate.png (14.45 KiB) Viewed 18103 times
ISECase.png (9.37 KiB) Viewed 18103 times

User avatar
Alexander Riedel
Posts: 7601
Joined: Tue May 29, 2007 4:43 pm
Answers: 2
Been upvoted: 6 times

Re: variable hashtable property view

Post by Alexander Riedel »

The ISE is not an editor. It is an interactive shell. To see what you want to see code must be executed. Without actually executing your module, it is not possible to determine what the content of your hash table would be.
We do not, under any circumstance, execute partial code to determine data content. That would be a huge security risk. We cannot just execute some module of unknown origin to provide intellisense.
If we were to do that, execute partial code that is, just because you opened a file, that would be scary.

Another reason we do not do this, is runspace contamination. In the ISE, if you run your script once, all data is retained in the runspace.
So whatever you do with $vmdata will always work as long as the ISE is open, even if you by accident delete the line containing 'getVMData'.
Even worse, variables can be set to some values from any number of previous scripts you ran. Since we all tend to re-use variable names, that is quite likely.
So your script in the ISE might work because variables have a value, but you actually never initialized them.

In PowerShell Studio every time you execute a script, it is running in a new runspace and a new process. Anything you missed to initialize will immediately become apparent.
Any data content you see is actually generated by your current script and not a remnant of something else you ran before lunch.

Last but not least, I need to point out there is absolutely no reason to use any one tool exclusively. It is absolutely normal to use the ISE to experiment and figure something out interactively
even though otherwise you use PowerShell Studio. I am a software developer and I use at least 4 different tools to wrestle with code at any given time. Each one does something the others don't or just not as good.
Alexander Riedel
SAPIEN Technologies, Inc.

Posts: 2
Joined: Tue Mar 03, 2020 2:21 pm

Re: variable hashtable property view

Post by Drunkpenguin »

Ah alright, makes sense.

I'm still partially new to the scripting department, so I'm still learning the rules :)

Thanks for your answer Alex and have a nice day