Have you tried using WMI for this?
gwmi -computer unity1 win32_service -filter "name='alerter'" |
foreach-object { if ($_.State -eq 'Running') {"Put your command here"}}
Now I wasn't clear if you wanted to run a command remotely, this example
will just execute a command on whatever machine is running the powershell
session.
"Blake" wrote:
Quote:
> I want to see if a service is RUNNING on a remote machine (it is a Windows
> 2000 server and can't run PS locally)
>
> since the remote service stuff doesn't seem fully functional in this
> release, I am trying to leverage PS and the 'sc.exe' command
>
> I have this:
>
> c:\windows\system32\sc \\unity01 query "alerter" | foreach {"$_"} |
> select-string "running"
> STATE : 4 RUNNING
>
> What I want is 'if there is some output, run another command'. So if the
> service is running, I do something else.
>
> Thanks
> Blake
>
>
>