Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Get-Service Command

$
0
0

I am writing a script that will monitor 5 services on a Windows 2008 server.   I was told by our server tech that sometimes that one of these five services can be "hung" yet in services.msc still show as "running".   So I did a get-help get-service -examples and under example 8 it says the following.

This command shows that when you sort services in ascending order by the value of their Status property, stopped services appear before running services. This happens because the value of Status is an enumeration, in which "Stopped" has a value of "1", and "Running" has a value of 4.

I have this in my script:   $result1 = (Get-Service "ILEDataInterfaceLayer" -ComputerName $Server).status   $result1 will contain "Running" or "Stopped" but how do I capture the "1" or "4" they speak of in the help example?

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles