Skip to content

Instantly share code, notes, and snippets.

@andreasohlund
Last active December 21, 2015 19:49
Show Gist options
  • Select an option

  • Save andreasohlund/6357225 to your computer and use it in GitHub Desktop.

Select an option

Save andreasohlund/6357225 to your computer and use it in GitHub Desktop.
$serviceName = "the name of the service"
$service = Get-Service $serviceName -ErrorAction SilentlyContinue
if ($service)
{
Stop-Service $ServiceName -Force
Start-Sleep -s 10
if($service.Status -ne 'stopped' ){
Write-Host "Waiting for the service to stop"
Start-Sleep -s 20
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment