I encountered a strange issue with a VPN adapter I use called ZeroTier. In short, the ZeroTier One client for Windows acts strange on Windows Server 2016. On a server reboot, the ZeroTier One.exe will run but won’t connect to the VPN. After investigation, I found the ZeroTier One service wasn’t running. In order to get the connection back up, I had to kill the process, start the service, then start the process. So, why not automate?

This can be used for a variety of processes. Here’s a Powershell template to use:

<#
This script will restart a service if it is found to not be running.

Edit the variable as required. To use, setup a scheduled task.
#>

$MyService = "SERVICE NAME HERE"

$TheService = Get-Service $MyService

if ($TheService.Status -ne "Running"){
    Start-Service $MyService
}

Save that as a Powershell script on your system, modify the service name, and setup a scheduled task and if the service isn’t running, it will start if it’s found to not be started! Hopefully this saves you a lot of hassle and headaches!

Share.

About Author

Hi! I'm Travis and I love technology.

Leave A Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.