Created
June 27, 2014 14:54
-
-
Save halr9000/a457fd519909a85c0027 to your computer and use it in GitHub Desktop.
PowerShell function to start Splunk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Start-Splunk { | |
try { | |
Get-Service splunk* | Start-Service -ErrorAction Stop | |
} | |
catch [Microsoft.PowerShell.Commands.ServiceCommandException] { | |
Write-Verbose "Command must be run in an elevated session, invoking new session." | |
Start-Process -Verb Runas -FilePath powershell.exe { Get-Service splunk* | Start-Service -Verbose -ErrorAction Stop; Start-Sleep 5 } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment