Open new shells for monitoring

Welcome Forums General PowerShell Q&A Open new shells for monitoring

This topic contains 9 replies, has 4 voices, and was last updated by

 
Participant
4 years, 4 months ago.

  • Author
    Posts
  • #16140

    Participant
    Points: 0
    Rank: Member

    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

    Moderator
    Points: 0
    Rank: Member

    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

    Participant
    Points: 0
    Rank: Member

    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

    Participant
    Points: 0
    Rank: Member

    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

    Participant
    Points: 0
    Rank: Member

    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

    Participant
    Points: 0
    Rank: Member

    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

    Participant
    Points: 0
    Rank: Member

    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

    Participant
    Points: 0
    Rank: Member

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

    • #16196

      Participant
      Points: 0
      Rank: Member

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

  • #16192

    Participant
    Points: 0
    Rank: Member

    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.

The topic ‘Open new shells for monitoring’ is closed to new replies.