I want to write a script to do troubleshooting one software--splunk forwarder:
1) test-connection
2) change path to c:\program files\splunk\
3) list forward-server
4) restart-service
Text
$ServerName = get-content "c:\computers.txt"
foreach ($Server in $ServerName) {
if (test-Connection -ComputerName $Server -Count 2 -Quiet ) {
write-Host "$Server is alive and Pinging " -ForegroundColor Green
} else
{ Write-Warning "$Server seems dead not pinging"
}
set-location c:\program files\splunk\bin
splunk list forward-server
} }