I had a software vendor supply us with a method of restarting the services for their application each night via a batch file that just:

  1. Performed a TASKKILL on 27 processes across 6 remote machines
  2. Called an external SLEEP.EXE file for a dumb wait period of 240s
  3. Then finally called another batch file that ran an SC START over the 27 services

This would hopefully result in restarted services. It worked … sometimes. When it didn’t work, we were unsure why because there was no logging.

This isn’t really the greatest solution; so I set about replacing this with a PowerShell script to manage the services, not just for this particular piece of software but to make it generic so it can be used for any service(s)/computer(s). It allows you to send ‘Start’, ‘Stop’, ‘Restart’, ‘Pause’ or ‘Resume’ actions to a service on the local or remote computer. I included complete logging, error handling and an optional force kill option if the service doesn’t stop nicely after x seconds.

See my GitHub repo below for more info…