Skip to content

Instantly share code, notes, and snippets.

@a5ync
Created April 20, 2016 00:51
Show Gist options
  • Save a5ync/4d4cf7f134a350481ba2c3d9bdb4d9a5 to your computer and use it in GitHub Desktop.
Save a5ync/4d4cf7f134a350481ba2c3d9bdb4d9a5 to your computer and use it in GitHub Desktop.
Check if windows service is installed and running
$serviceName = "Dhcp"
$service = Get-Service $serviceName -ErrorAction SilentlyContinue
if($service)
{
Write-host service $service.Name is $service.Status
}
else
{
Write-host what service?
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment