Skip to content

Instantly share code, notes, and snippets.

@spy86
Created December 6, 2018 16:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spy86/4e5c0d3ecab7c536681180a14e3e0fb2 to your computer and use it in GitHub Desktop.
Save spy86/4e5c0d3ecab7c536681180a14e3e0fb2 to your computer and use it in GitHub Desktop.
Function to Check Service in Windows
function FuncCheckService{
param($ServiceName)
$arrService = Get-Service -Name $ServiceName
if ($arrService.Status -ne "Running"){
Start-Service $ServiceName
Write-Host "Starting " $ServiceName " service"
" ---------------------- "
" Service is now started"
}
if ($arrService.Status -eq "running"){
Write-Host "$ServiceName service is already started"
}
}
FuncCheckService
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment