so I have two .ps1 scripts that check for new Tasks every 60 seconds and I want to run them at the same time. I use them every day and starting them gets a little annoying. Ideally, I want to write a script that I can run that runs those two for me.
The Problem is that as they don't stop at some point, I can't just start them one after the other and I can't find a command to open a new PS ISE instance. However, one instance can't run both scripts at the same time. The Ctrl+T Option would be perfect, but I can't find the equivalent command.
Does anyone have an idea on how to solve this? Thanks!
I think what you want is something like
Start-Process Powershell.exe -Argumentlist "-file C:\myscript.ps1"
Start-Process Powershell.exe -Argumentlist "-file C:\myscript2.ps1"
In addition to that: Use Import-Module $Modulepath
inside the scripts to ensure the availability of the modules.
If you have Powershell 3.0+ you could use workflows
. they are similar to functions, but have the advantage that you can run commands parallel.
so your workflow would be something like this:
workflow RunScripts {
parallel {
InlineScript { C:\myscript.ps1 }
InlineScript { C:\myotherscript.ps1 }
}
}
keep in mind that a workflow behaves like a function. so it needs to be loaded into the cache first, and then called by running the RunScripts
command.
more information: https://blogs.technet.microsoft.com/heyscriptingguy/2013/01/09/powershell-workflows-nesting/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With