Is there any way to run a script and have it open new shells that run their part of the program. So I start a script and if it references a subroutine that is its own PowerShell script, can I make it open a new shell so I can watch it run?
I’m not sure if I understand the scenario correctly but I can offer an idea how to open new detached shells running another script or the same script with parameters.
Start-Process -FilePath PowerShell.exe -ArgumentList ‘-File PingMonitor.ps1’, ‘-SystemGroup Webserver’
Can you elaborate a little more on what you’re trying to do? If you just want to spawn another powershell.exe process you can just put something like this in a script.
powershell.exe -FilePath C:\Somescript.ps1
Let’s say I run a script against 5 servers. I want the script that I am running to open up new shells for each server and show the progress of each server independently. Like running a jobs, but it actually open a new shell.
Can I ask why it matters that multiple shells are open? I’ve personally never ran into a situation where I needed to explicitly specify different shells. Perhaps there’s a better way to get done what you need.
start-process powershell -argumentlist “-noexit -command Get-process”
This works perfect!
It’s probably not a good reason, but our team lead built a script for patching all the windows servers and the script used perl, psexec and powershell. I wanted to rewrite it all in PowerShell, but one of the things that the team likes is that when they run the script it opens a dos shell for each server so they can monitor the progress of each one and if it fails or stops, they can address that server individualy.
I got this answer from another forum.
Thanks for your responses.
I see. Thanks. I’m glad you got what you were looking for. However, what you’re doing could easily be accomplished and much-simplified via a single Powershell script. Perhaps this would be a good opportunity to take on a new project!
That is what I am saying, I want to rewrite the whole thing in one PowerShell script.
Can you post your code, explain what is occurring and what the expected result is? If the code is lengthy, save it as a .TXT file and upload it to your post.
Oh, sorry about that. I misunderstood. If you’d like, explain what you’re doing further and we can help.