Created
December 6, 2018 16:36
-
-
Save spy86/4e5c0d3ecab7c536681180a14e3e0fb2 to your computer and use it in GitHub Desktop.
Function to Check Service in Windows
This file contains hidden or 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 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