Suppose I launch a powershell script and it’s running in a loop.
I open a second ps console and launch a second script. In this script I want to detect if the first script is running or not.
What are the ways to achieve this?
Suppose I launch a powershell script and it’s running in a loop. I open
Share
If you’re looking at opening 2 separate consoles, you’ll need to add some logic in your script to do some changes to the file system, registry or even the title bar of your PowerShell session where it is running. Then you can use some logic in your 2nd console to look for that information.
One other method, that I typically use, is with WMI:
An example:
This means that you need to call powershell.exe to run your script though.