Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - remote service

Reply
 
Old 10-02-2008   #1 (permalink)
Blake


 
 

remote service

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



My System SpecsSystem Spec
Old 10-02-2008   #2 (permalink)
PaulChavez


 
 

RE: remote service

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
>
>
>
My System SpecsSystem Spec
Old 10-03-2008   #3 (permalink)


Vista Ultimate 32bit
 
 

Re: remote service

Although you can still use WMI to remotely manage the server. Here's another way: Managing Services with PowerShell and ADSI | SAPIEN Technologies
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Remote Assistance w/Service Pack 2 Vista General
stopping remote service from VM PowerShell
Remote Regestry Service Vista General
Remote Installation Service Vista installation & setup
MSN Remote Record Service Fails Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46