Powershell has a Start-Service command that can be used to start a Windows service. Here’s a function to check if a service has been stopped, and to start it if it has.
function StartService ([string] $ServiceName) {
$ServicePrior = get-service $ServiceName
if ($ServicePrior.status -eq “Stopped”) {
Start-Service $ServiceName
Write-Host “Started Service ” $ServiceName
}
}
Call by:
StartService MSSQL`$SQL2012EVAL
The tick is to escape the dollar sign in the service name.
Stop-Service will stop the service.