When debugging a script, PS Studio starts a new PowerShell process each time debugging starts. Is it possible to reuse the same PowerShell process, like PowerShell ISE?
Product, version and build: PowerShell Studio 2017 5.4.144
32 or 64 bit version of product: 64
Operating system:
32 or 64 bit OS: 64
PowerShell Studio: Reuse PowerShell Process
Forum rules
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE 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.
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE 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.
- Alexander Riedel
- Posts: 8479
- Last visit: Thu Mar 28, 2024 9:29 am
- Been upvoted: 37 times
Re: PowerShell Studio: Reuse PowerShell Process
For just running the script you can run it in the embedded shell. That will persist after the script is finished.
For debugging, no. It is not advisable to re-use a runspace for debugging repeatedly, as the runspace would be contaminated by the previous execution of the script. For debugging you need reproducible results.
Is there a particular reason you ask for this?
For debugging, no. It is not advisable to re-use a runspace for debugging repeatedly, as the runspace would be contaminated by the previous execution of the script. For debugging you need reproducible results.
Is there a particular reason you ask for this?
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: PowerShell Studio: Reuse PowerShell Process
Thanks for the clarification.
When developing a script, I often debug the script after incremental changes to test new code or to inspect variables. E.g., I hit a breakpoint, and notice that I need to modify the code. I can terminate the debugging session, make minor adjustments, and initiate a new debugging session.
I'm just trying out PS Studio, but from my initial experiences, what I can accomplish in 1-2 minutes with ISE takes 10+ with PS Studio. The overall development experience is much better, but with the specific workflow I outlined, ISE is much more usable.
It would be nice if there was an option or separate command that controls whether a runspace can be re-used. Or, similar to ISE, breakpoints could be enabled for scripts executed using the embedded console.
When developing a script, I often debug the script after incremental changes to test new code or to inspect variables. E.g., I hit a breakpoint, and notice that I need to modify the code. I can terminate the debugging session, make minor adjustments, and initiate a new debugging session.
I'm just trying out PS Studio, but from my initial experiences, what I can accomplish in 1-2 minutes with ISE takes 10+ with PS Studio. The overall development experience is much better, but with the specific workflow I outlined, ISE is much more usable.
It would be nice if there was an option or separate command that controls whether a runspace can be re-used. Or, similar to ISE, breakpoints could be enabled for scripts executed using the embedded console.
- Alexander Riedel
- Posts: 8479
- Last visit: Thu Mar 28, 2024 9:29 am
- Been upvoted: 37 times
Re: PowerShell Studio: Reuse PowerShell Process
The process is pretty much the same, you stop debugging, make adjustments and start again. I don't really see where this would take longer, except for maybe powershell engine startup. Re-using the runspace would not result in anything faster, it would just make sure that you miss uninitialized variables and other conditions caused by runspace contamination. At this point I usually point out that no other language would ever allow you to re-run a process in a contaminated environment (that I am aware off).
At any rate, the ISE is something you have. There is no mutual exclusivity here and I know of a few cases where using the ISE is beneficial to locating particular problems. In general there never is a catch-all tool and we always encourage everyone to have a wide variety of tools at their disposal and be familiar with all of them.
So if your experience is that for certain cases the ISE gives you faster results, use it. We won't judge
PowerShell Studio was not meant to replace the ISE, since that is something you already have.
I hope that helps.
At any rate, the ISE is something you have. There is no mutual exclusivity here and I know of a few cases where using the ISE is beneficial to locating particular problems. In general there never is a catch-all tool and we always encourage everyone to have a wide variety of tools at their disposal and be familiar with all of them.
So if your experience is that for certain cases the ISE gives you faster results, use it. We won't judge
PowerShell Studio was not meant to replace the ISE, since that is something you already have.
I hope that helps.
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: PowerShell Studio: Reuse PowerShell Process
Yes, your explanation helps, thank you.
I should have been specific. The reason for the delay is precisely what you mentioned – The PS engine startup time. It generally takes several seconds for PowerShell to startup with the default terminal and ISE. However, with ISE it only occurs once so it's a bit easier to manage.
Is there anything I can do to speedup the PowerShell engine startup when debugging with PS Studio?
I should have been specific. The reason for the delay is precisely what you mentioned – The PS engine startup time. It generally takes several seconds for PowerShell to startup with the default terminal and ISE. However, with ISE it only occurs once so it's a bit easier to manage.
Is there anything I can do to speedup the PowerShell engine startup when debugging with PS Studio?
- Alexander Riedel
- Posts: 8479
- Last visit: Thu Mar 28, 2024 9:29 am
- Been upvoted: 37 times
Re: PowerShell Studio: Reuse PowerShell Process
It shouldn't really take all that long. Can you give me a number of how long that takes for you? Is this a VM?
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: PowerShell Studio: Reuse PowerShell Process
I manually timed a few sessions:
Steps to Reproduce:
Steps to Reproduce:
- Set a breakpoint on the first line of a script
- Debug the script
- Wait for breakpoint to be hit
- Press CTRL+F5, then F5 to start a new debugging session
- Wait for breakpoint to be hit
- On average, 12-15s elapse between Steps 4 & 5
Re: PowerShell Studio: Reuse PowerShell Process
This is a physical machine.
Specs:
Windows 10 Pro 64-bit
Intel Core i7 6600U @ 2.50GHz
16.0GB Dual-Channel DDR3 @ 797MHz (12-15-15-34)
SSD
Specs:
Windows 10 Pro 64-bit
Intel Core i7 6600U @ 2.50GHz
16.0GB Dual-Channel DDR3 @ 797MHz (12-15-15-34)
SSD
- Alexander Riedel
- Posts: 8479
- Last visit: Thu Mar 28, 2024 9:29 am
- Been upvoted: 37 times
Re: PowerShell Studio: Reuse PowerShell Process
I'll give that QA to see what they can find out about this. Thanks for sending the data.
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.