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

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

post - imageshack API cURL -