Our Blog

Set service recovery options in PowerShell

Recently one of our Administrators reported that he had to manually startup some Pulseway services after windows updates. It sometimes happens that during Windows updates on hosts machines get into Paused state and when they come back the service goes down and stays down. The way to fix it is to set service recovery options. Since it's possible that first 2 tries will fail I wanted to fix this so it would keep Pulseway up and running always.

Solution

Since at the moment PowerShell doesn't allow to modify this settings one has to use SC.EXE to set failure options. Following script utilizes sc.exe and allows you to set actions for:

First failure
Second failure
Subsequent failure

Script has 2 mandatory parameters:
Service Display Name
ServerName

The rest of parameters are optional.

Keep in mind this script doesn't use Service Name but Display Name.

I've chosen this approach due to different naming of services. This is true for Pulseway which used to be called PC Monitor.

Tags: , , , , , , , ,

This is a unique website which will require a more modern browser to work! Please upgrade today!