If I run get-service it may return different statuses (0-4/Running, Stopped, Stopping, Running). Can I somehow expand a list of possible values for status by issuing PowerShell commandlet?

I tried to do this by using something like | select $.status -Expand property, but was not able to get this information.

I want to know how to do it that way (I know that I can find list of possible values in the documentation). I need to use these values in conditions in subsequent steps of my script, and I want to be sure that I covered all possible values returned.


Get-Service calls .Net and creates objects using a constructor in the System.ServiceProcess.ServiceController class. You can find out what "type" the data is by piping the cmdlet to Get-Member like this:

Get-Service | Get-Member

The Get-Member command is actually enumerating the methods and properties of the object created by Get-Service as well as it's TypeName. You can see the TypeName immediately after entering the command.

That TypeName corresponds to a .Net class which you then google (no really). You have to drill through the msdn page a bit which requires a basic understanding of object oriented programming (I know, another google). Eventually you should land on the ServiceControllerStatus Enumeration page which lists all the possible value descriptions.

The values returned are actually integers, but .Net is kind enough to turn those values into something we can understand. Hopefully if you practice this process a little, you'll be able to apply this same method to find info on other objects in powershell.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.