Last active
October 22, 2021 19:34
-
-
Save greenygh0st/a63a806760be1ddd27acd6cccf4dc7d2 to your computer and use it in GitHub Desktop.
A script for starting and stepping Windows services in a controlled and non-error inducing way...
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
$ServiceName = 'Serenade' | |
$arrService = Get-Service -Name $ServiceName | |
while ($arrService.Status -ne 'Running') | |
{ | |
Start-Service $ServiceName | |
write-host $arrService.status | |
write-host 'Service starting' | |
Start-Sleep -seconds 5 | |
$arrService.Refresh() | |
if ($arrService.Status -eq 'Running') | |
{ | |
Write-Host 'Service is now Running' | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment