editing question

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

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 6 years and 9 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.
Locked
User avatar
draeger_lutz
Posts: 11
Last visit: Fri Feb 03, 2023 2:06 pm

editing question

Post by draeger_lutz »

Hello to all users of Sapien Powershellstudio. I am a beginner. In Windows Powershell ISE, the upper window is used for scripting.
I am using the other windows (bottom) for testing and coding. This is very helpfull, the workspace is the same as for the script.
All Variables are well known there. But, in Sapien Powershellstudio i am missing this behavoir. I don´t knew, how to deal with variables
and funktions in the same manner, as explained before, there is no interactive window, as in Windows ISE.
What can i do now ?
Thanks for any help.
:idea:
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: editing question

Post by Alexander Riedel »

That is a good question. There are two answers to this, because this is a little bit of a philosophical difference.
In general PowerShell Studio runs a script each and every time in a new runspace to prevent what is called "runspace pollution"
Let's assume your script only works if a variable $ServerArray actually has some values. Since you ran a previous script that used that variable in the ISE, your other script will work fine in the ISE.
$ServerArray has content and you will not notice the dependency. As soon as you load your script on another machine or just the next day on your computer, it appears broken.
Running your script in a new runspace every single time will reveal any dependency on uninitialized variables immediately.
In short, PowerShell Studio work more like an IDE for any other language. Everything runs in a new process.

But of course sometimes it is very convenient to be able to examine variables and results after the fact to determine what went wrong or to verify tests.
You can always run your script in the integrated console (Ctrl+F8) and look there after it ran.

I hope this help.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
lupus1
Posts: 1
Last visit: Sun Apr 22, 2018 8:55 am

Re: editing question

Post by lupus1 »

Hello alexander,
thanks for reply. Yes, you explained the problem with Powershell ISE when assuming that "hidden" values are used and the next run the script won´t work,
i noticed that behaivor before. You are telling me, that CRTL + F8 shows the results of the last script-run - o.k. But, there is another way: Debugging and locking
for the variables on runtime of the script. This may help a bit. But, as a beginner, i am not shure on using commandlets etc. in the right manner.
Threfore, the behaivor of the MS-ISE is very helpfull: I copy some parts of the code into the window on the bottom and start this fragment with one ore two commandlets only.
The result shows me, if i coded some errors or did not understand exactly, how the commandlet works ...
Then i can correct the script above and in this manner, the script becomes better and works on the end fine.

In MS-ISE this style of working runs fine and i must not alter the code / script for testing some parts of it. Sorry, but this missing behaivor is the biggest malus on Sapien Powershell studio. For me,
it is very hard to write scripts on Powershell studio and i prefer the MS-ISE. Or, did i understand something wrong ?
I would like to use the benefits of Sapien Powershell studio, but how to solve my problems ?

-Greetings
Dr.
User avatar
pdelossantos
Posts: 2
Last visit: Thu Apr 18, 2019 2:04 pm

Re: editing question

Post by pdelossantos »

I am also a beginner with PowerShell Studio 2017. I have used ISE and PowerGUI before (PowerGUI was nice because you could change the behavior and reset runspace at will if needed). As I play with PowerShell Studio, and I want to be able to easily view contents of a variable, I will set breakpoints as needed. I can then hover on the variable in the script pane to see its contents or view the Variables pane below the script pane.
User avatar
draeger_lutz
Posts: 11
Last visit: Fri Feb 03, 2023 2:06 pm

Re: editing question

Post by draeger_lutz »

pdelossantos wrote:I am also a beginner with PowerShell Studio 2017. I have used ISE and PowerGUI before (PowerGUI was nice because you could change the behavior and reset runspace at will if needed). As I play with PowerShell Studio, and I want to be able to easily view contents of a variable, I will set breakpoints as needed. I can then hover on the variable in the script pane to see its contents or view the Variables pane below the script pane.
Hello,
thanks for your reply. I agree with you and i am still working with PowerGUI more often then PowershellStudio. You are using the breakoint / debugging as i do also. But, how to write a quick expression in the same runspace the script is in ? In PowerGUI / MS-ISE it is very easy to write in the same runspace, but unfortunatly not here. This is the biggest disadvantage, in my opinion.

-greetings
L.
User avatar
pdelossantos
Posts: 2
Last visit: Thu Apr 18, 2019 2:04 pm

Re: editing question

Post by pdelossantos »

Did you try clicking the Run drop down and choosing "Run in Console?" The console will then have all variables available and you can write an expression using them. I just now tried this for the first time.
User avatar
draeger_lutz
Posts: 11
Last visit: Fri Feb 03, 2023 2:06 pm

Re: editing question

Post by draeger_lutz »

pdelossantos wrote:Did you try clicking the Run drop down and choosing "Run in Console?" The console will then have all variables available and you can write an expression using them. I just now tried this for the first time.
Hello,
:idea:
thanks, that may help. But Intellisense does not work, that means, you must knew and enter the expressions exactly.
Another question is: How to shrink the menues on top of the screen ? There are so many windows - there is only about 40% of the entire
screen left over for the actual program-code. Ok. - this is an other question ... :mrgreen:

greetings
L.
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: editing question

Post by Alexander Riedel »

Let me jump in her one more time. :D PowerShell Studio was not designed to replace the ISE. The ISE is a console and a great learning tool. You already have it, so we would not waste time and try to recreate it. In general you cannot always replace one tool with another. Use the best tool for the job at hand. So if you are experimenting with unfamiliar code, fire up the ISE, why not?

As to the "shrink menus" question, the ribbon in most applications has a collapse button. Look on the top right or use Ctrl+F1.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
draeger_lutz
Posts: 11
Last visit: Fri Feb 03, 2023 2:06 pm

Re: editing question

Post by draeger_lutz »

Alexander Riedel wrote:Let me jump in her one more time. :D PowerShell Studio was not designed to replace the ISE. The ISE is a console and a great learning tool. You already have it, so we would not waste time and try to recreate it. In general you cannot always replace one tool with another. Use the best tool for the job at hand. So if you are experimenting with unfamiliar code, fire up the ISE, why not?

As to the "shrink menus" question, the ribbon in most applications has a collapse button. Look on the top right or use Ctrl+F1.
Hi Alexander,
thanks for reply and don´t get me wrong, please. Sorry, i don´t want somebody to wast his time, that´s for shure. It´s that what you said - i am still learning writing P=owershell-code. If there is no other way, i will use ISI parallel. And pleas let me say that - Sapien Powershellstudio is a great tool !

Have a nice day :D

L.
This topic is 6 years and 9 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.
Locked