I want to find a script to list splunk forwarder status the restart the service if the listing failed.
$serverlist =
"C:\serverlist.txt"
Get-Content $serverlist |
foreach($comp in
$serverlist){Invoke-Command
-ComputerName $_ -FilePath "C:\Program Files\SplunkUniversalForwarder\bin\splunk.exe"
-ArgumentList splunk list forward-server}
Or
$sstat = Get-Service -Name splunkd
#Checks for Service Status
#Restarts Splunk Service if it's running, or starts if it is stopped
if ($sstat.status -eq "running"){
write-output "Restarting Splunk"
restart-service splunkd
}
elseif ($sstat.status -eq "stopped"){
start-service splunkd
write-output "Splunk is starting"
}
... View more