Check if Service is Running or Stopped and Output accordingly
<p>I'm just starting off with Powershell and want to run some basic scripts.</p>

<p>I'm starting off by writing a script to see if MSSQLSERVER is running or stopped and out a message accordingly.</p>

<p>This is what I have so far...</p>

<pre><code>Write-Host "Checking if SQL Server is running.."

function FuncCheckService{
param($MSSQLSERVER)
$arrService = Get-Service -Name $MSSQLSERVER
if ($arrService.Status -eq "Running"){
Write-Host "Service is running" 
}
if ($arrService.Status -eq "Stopped"){ 
Write-Host "service is stopped"
}
}
</code></pre>

<p>However when I execute this (within Powershell ISE) all I get is the first line "Checking if SQL Server is running..."</p>

<p>What am I doing wrong with this?</p>