Configure PS to shut down a service and then monitor processes.

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Mohit Sood Mohit Sood 3 months, 1 week ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #44542
    Profile photo of Mohit Sood
    Mohit Sood
    Participant

    Hi,

    I am new Powershell and was hoping to get some guidance on one project i am working on:-

    I want to stop a service and set it disabled :- Done

    After shutting the service down i want to monitor some processes that needs get shut down automatically (Cant end them as requirement) and then restart my server once all listed processes are not running.

    Any guidance will be help.

    Thanks.

    • This topic was modified 3 months, 1 week ago by Profile photo of Mohit Sood Mohit Sood.
    #44564
    Profile photo of Rob Simmers
    Rob Simmers
    Participant

    You can do looping, which you may want to consider if you want to do a timeout and force a reboot. However, you can try this simple approach to get multiple processes and then have it wait until the processes have exited. Try this out and see if it will work out for you.

    $proc = Get-Process -Name notepad, mspaint -ErrorAction SilentlyContinue
    $proc.WaitForExit()
    
    "Restart Server"
    
    #44598
    Profile photo of Mohit Sood
    Mohit Sood
    Participant

    Let me give it a shot.

    Thanks Rob.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.