I was sitting in on our recent PowerShell training class, and I observed our amazing trainer, Jason Yoder, field a question from a new PowerShell user asking why she couldn’t edit her script in PowerShell Studio. It turns out that the GUI script was still running in the background.
Have you ever found yourself in a similar situation?
Typical PowerShell scripts will execute line-by-line to the end and stop. Unlike normal linear scripts, GUI scripts will continue to run unless you close the window:
If you are new to GUI scripts, it is easy to forget that you have to click on the window’s X button before editing your script.
When PowerShell Studio is running a script, it prevents you from editing files. It does this to keep the debugger synchronized with the file in the editor and prevents misalignment of line errors and output. In certain circumstances, an active GUI designer can also interfere with the running script.
Next, let’s cover the PowerShell Studio cues that indicate a script is running.
We made a change to help address this issue. When you run a script in PowerShell Studio 2019 (v5.6.161 and up), the document tabs now display a running image overlay:
The running script will have a green overlay icon, and all other files will have a gray overlay icon. This distinction makes it easier to determine which scripts you are debugging / running.
When running a script, the Run and Debug buttons are disabled:
The editor’s border will change depending on if you are debugging a script or just running a script:
The GUI designer is disabled and blank during script execution:
The status bar is another place where you can determine if a process is running:
You can use the status bar to stop the running script:
As you can see, there are various UI cues in PowerShell Studio that indicate a script is running. We hope that this document tab change makes it easier to see when a script is running, including which script.