determine service status (Full Version)

All Forums >> [Scripting Technologies] >> Windows PowerShell



Message


phenry194 -> determine service status (10/7/2008 5:56:49 PM)

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!  : )




SAPIENScripter -> RE: determine service status (10/8/2008 7:30:12 AM)

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 }




phenry194 -> RE: determine service status (10/8/2008 1:40:00 PM)

thanks for the info!  : )




phenry194 -> RE: determine service status (10/8/2008 7:21:21 PM)

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!  : )




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.1875