Menu Close

Restart services and e-mail succes (Powershell)

This script was originally created to run as a scheduled task. All variables will have to be updated to fit with your own environment i.e. $hostname, $smtpserver. Once run it will complete the following –

1. Send an e-mail to whichever address/s that you specify within the $recipients variable. In my case this was used to inform the alert monitoring team that they can ignore alerts for this service over the next 10 mins.

2. Stop the service specified within the $service variable. A do..Until loop was used to confirm the service had stopped before continuing with the script.

3. Start the service. Again, a do..Until loop was used to confirm the service had started.

4. Send an e-mail to the same recipients informing them that the service has restarted successfully.