myITforum.com Community Forum myITforum.com Community Forum

Home  Forums  Blogs  Live Support chat  Search Articles  Wiki  FAQ  Email Lists  Register  Login  My Profile  Inbox  Address Book  My Subscription  My Forums 

Photo Gallery  Member List  Search  Calendars  FAQ  Ticket List  Log Out

All Forums RSS Feed Subscription:


  


determine service status

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
  Printable Version
All Forums >> [Scripting Technologies] >> Windows PowerShell >> determine service status Page: [1]
Login
Message << Older Topic   Newer Topic >>
determine service status - 10/7/2008 5:56:49 PM   
phenry194

 

Posts: 196
Score: 0
Joined: 3/30/2007
Status: offline
I wanted to know if there is a powershell script that I can run against a collection of machines that will tell me the status of a particular service.  I know you can look at all the services of a particular machine, but I want to look at one service on a group of machines.  I am pretty new to PowerShell, but I figure there is something out there.  Thanks!  : )
Post #: 1
RE: determine service status - 10/8/2008 7:30:12 AM   
SAPIENScripter

 

Posts: 100
Score: 0
Joined: 5/15/2007
From: SAPIEN Technologies
Status: offline
Use the Get-WMIObject to  get service objects.  Since you only want a particular service, you would use something like this:

get-wmiobject win32_service -computername SERVER01 -filter "name='spooler'" | Select SystemName,State

To process a text list of computers,
get-content servers.txt | foreach { get-wmiobject win32_service -computername SERVER01 -filter "name='spooler'" | Select SystemName,State }


_____________________________

Jeffery Hicks
Microsoft MVP - Windows PowerShell
http://blog.SAPIEN.com
coming soon: Managing Active Directory with Windows PowerShell: TFM
followme: http://www.twitter.com/jeffHicks

(in reply to phenry194)
Post #: 2
RE: determine service status - 10/8/2008 1:40:00 PM   
phenry194

 

Posts: 196
Score: 0
Joined: 3/30/2007
Status: offline
thanks for the info!  : )

(in reply to SAPIENScripter)
Post #: 3
RE: determine service status - 10/8/2008 7:21:21 PM   
phenry194

 

Posts: 196
Score: 0
Joined: 3/30/2007
Status: offline
Ok, so with your input this is what I came up with:

$computers = get-content "c:\temp\facrecPCs.txt"
foreach ($computer in $computers)
{ get-wmiobject win32_service -computername $computer -filter "name='datbase gateway'" | Select SystemName,Name,State | out-file f:\powershell\facrec.txt -append}

What I would like to know is how I can generate a report without it printing the headers above each entry like it is doing with the script above.  I tried a number of things but no luck.  Is there a way to do this?  Thanks!  : )

(in reply to phenry194)
Post #: 4
Page:   [1]
All Forums >> [Scripting Technologies] >> Windows PowerShell >> determine service status Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts



  
Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

0.391