Open new shells for monitoring

This topic contains 9 replies, has 4 voices, and was last updated by  Adam Bertram 3 years, 2 months ago.

  • Author
    Posts
  • #16140

    Dan Iverson
    Participant

    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?

  • #16142

    Daniel Krebs
    Moderator

    Dan,

    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'

  • #16143

    Adam Bertram
    Moderator

    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
    
  • #16173

    Dan Iverson
    Participant

    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.

  • #16174

    Adam Bertram
    Moderator

    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.

  • #16177

    Dan Iverson
    Participant

    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.

  • #16179

    Adam Bertram
    Moderator

    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! 🙂

  • #16191

    Dan Iverson
    Participant

    That is what I am saying, I want to rewrite the whole thing in one PowerShell script.

    • #16196

      Adam Bertram
      Moderator

      Oh, sorry about that. I misunderstood. If you'd like, explain what you're doing further and we can help.

  • #16192

    Rob Simmers
    Participant

    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.

You must be logged in to reply to this topic.