Skip to content

Commit

Permalink
Create Check-ServiceHealth.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
rswio authored Jan 26, 2025
1 parent 31c23ce commit 191d59f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Monitoring/Check-ServiceHealth.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
$Servers = @("Server1", "Server2") # Replace with the names of your servers
$ServiceName = "Spooler" # Replace with the service name you want to monitor

foreach ($Server in $Servers) {
$Service = Get-Service -Name $ServiceName -ComputerName $Server
if ($Service.Status -ne "Running") {
Start-Service -Name $ServiceName -ComputerName $Server
Write-Output "Started $ServiceName on $Server"
}
}

0 comments on commit 191d59f

Please sign in to comment.