powershell - Check if Service is Running or Stopped and Output accordingly -


i'm starting off powershell , want run basic scripts.

i'm starting off writing script see if mssqlserver running or stopped , out message accordingly.

this have far...

write-host "checking if sql server running.."  function funccheckservice{ param($mssqlserver) $arrservice = get-service -name $mssqlserver if ($arrservice.status -eq "running"){ write-host "service running"  } if ($arrservice.status -eq "stopped"){  write-host "service stopped" } } 

however when execute (within powershell ise) first line "checking if sql server running..."

what doing wrong this?

your function fine never call it. @ end of scripts, past last curly braces put function name.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -