Windows Vista Forums
Vista Forums Home Join Vista Forums Donate 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 Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

remote service

Reply
 
LinkBack Thread Tools Display Modes
Old 10-02-2008   #1 (permalink)
Blake
Guest


 
 

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)
Blake
Guest


 
 

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   #3 (permalink)
PaulChavez
Guest


 
 

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-02-2008   #4 (permalink)
PaulChavez
Guest


 
 

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   #5 (permalink)
sapienscripter's Avatar
Scripting Guru


Join Date: Jun 2008
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
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to start a remote service under a different user name Flea# PowerShell 2 01-23-2008 05:26 AM
How to check service packs on remote computers. Damon PowerShell 3 04-12-2007 10:00 PM
Remote Regestry Service CoCUser Vista General 0 04-05-2007 07:21 AM
Remote Installation Service =?Utf-8?B?QW5kcmVhcyBIZW5uaWc=?= Vista installation & setup 4 09-25-2006 02:36 AM
MSN Remote Record Service Fails =?Utf-8?B?RGF2aWQgRGVMZWxsYQ==?= Vista General 0 09-13-2006 10:37 PM


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 47 48 49 50 51 52 53