Last time we discussed how to handle Windows services with Microsft Powershell. This time we get a little deeper by restarting multiple services at once with an additional check if they all restart successful.
The challenge
Let’s take a real example where one software installs three services. I often use GFI Faxmaker. It can works as a fax server behind a telephone system and is usually connected through SIP or H323. To send outbound faxes it has to receive the fax from the client as SMTP mail. Therefore the Microsoft SMTP Server service is also needed. Let’s guess we want to restart all relevant services. So we have to restart three services that come with GFI Faxmaker and the Microsft SMTP Service.
Just restarting a service is not a big deal but don’t we want to check wether all services run after the restart? Wouldn’t it be bad if we restart four services but only two of them come up again? So we will check the state of the service and if they don’t start again successfully we want to send an email to have a chance to act.