Skip to content

Commit 1e5947e

Browse files
authored
Add files via upload
1 parent 42face6 commit 1e5947e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

service_checker.ps1

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# This script will check the listed services in the array below and attempt to start them if they are stopped. If the service is disabled, it won't be able to start it. This script should be ran as often as needed to verify the services are running as expected.
2+
# Replace Service1 and Service2 with the services needed. You can add more to the array as needed.
3+
# Depending on your setup, you many need to set "Set-ExecutionPolicy" on the machine to allow unsigned scripts to run.
4+
# Another option would be to run this script with the following command "Powershell.exe -executionpolicy bypass -Command service_checker.ps1"
5+
6+
$services = @("Service1","Service2")
7+
8+
#Restart services that are stopped.
9+
foreach($service in $services) {
10+
$VerifyServiceStopped1 = Get-Service $Service1 | Where-Object {$_.status -eq "Stopped"} | select -last 1
11+
if ($VerifyServiceStopped1) {
12+
start-service -Name $service
13+
}
14+
}

0 commit comments

Comments
 (0)