value of property

This topic contains 0 replies, has 1 voice, and was last updated by Profile photo of Forums Archives Forums Archives 5 years, 5 months ago.

  • Author
    Posts
  • #5443

    by lopyeg at 2013-01-16 06:28:41

    Hello guys!
    Sorry for noob question.
    How can I get all available values of the object property? My english is bad, so i append my question with an example
    we have cmdlet get-service. Object cmdlets returns has a property Status.
    PS C:\Users\lopyeg> (get-service)[2] |get-member

    TypeName: System.ServiceProcess.ServiceController

    Name MemberType Definition
    ---- ---------- ----------
    Name AliasProperty Name = ServiceName
    ...
    Status Property System.ServiceProcess.ServiceControllerStatus Status {get;}

    Question: How can I see all available values of Status (running| stopped| paused maybe)?

    is it important for discovering powershell and selecting...

    thank you for response

    by ArtB0514 at 2013-01-16 07:47:35

    Get-Service[2] | Format-List *

    by lopyeg at 2013-01-16 07:51:27

    it returns only
    Status : Stopped
    but not all vailable values of Status

    by Klaas at 2013-01-16 07:55:38

    Get-Service | Group status

    by ArtB0514 at 2013-01-16 07:58:45

    So sorry, I misunderstood your question and thought you wanted all properties from a single service.

    by lopyeg at 2013-01-16 08:03:40

    no i want to get all possible values from some property

    i want to know does Status be equal "paused", for example

    by lopyeg at 2013-01-16 08:07:04

    (Get-Service)[2].status |get-smthmagic
    StatusCanBe Value
    ————— ———
    stopped
    running
    hanging
    paused

    by ArtB0514 at 2013-01-16 08:29:47

    You can only retrieve the status values that are actually in use on a system (Use Klaas's method to achieve this). In order to find all the possible status values, whether they actually exist on a server or not, you'll need to find it in MSDN. It looks to me like the values are in the ServiceControllerStatus enumeration. You can find it at
    http://msdn.microsoft.com/en-US/library/system.serviceprocess.servicecontrollerstatus(v=vs.80).aspx
    The values are]
    ContinuePending
    Paused
    PausePending
    Running
    StartPending
    Stopped
    StopPending
    [/list]

    by lopyeg at 2013-01-16 09:09:23

    Thank you for response

    the Service status was an example)
    is it some cmdlet to get values of any property?
    for AD objects for example?

    by nohandle at 2013-01-16 09:34:45

    Hi,
    to be able to retrieve all of the available values they must be taken from a final set, in case of .net it is usually enum. To learn if the property you are interested in is enum look at its base type.
    $statusValue = Get-service | select -First 1 | select -ExpandProperty status
    $statusValue.getType()

    IsPublic IsSerial Name BaseType
    -------- -------- ---- --------
    True True ServiceControllerStatus System.Enum

    If the base type is enum you can use static methods of the enum class to list the available values of the type:
    [Enum]]
    Stopped
    StartPending
    StopPending
    Running
    ContinuePending
    PausePending
    Paused

    by lopyeg at 2013-01-17 01:13:52

    Thanks a lot for the help
    I guess it will be interesting for all PS users
    and very useful

    i will write it in function.

    best regards

    by nohandle at 2013-01-17 01:58:53

    Great. Please share it afterwards 🙂

    by lopyeg at 2013-01-21 02:49:36

    it seems, i am to young in PoSh)))
    i could not write a function...

    by Infradeploy at 2013-01-21 03:20:48

    if your run 'get-service|gm'
    Status Property System.ServiceProcess.ServiceControllerStatus Status {get;}

    And if you look up the System.ServiceProcess.ServiceControllerStatus Status .NET in Powershell:
    [enum]::GetValues("System.ServiceProcess.ServiceControllerStatus")
    You'll get the values mentioned above

    (Credit for this goes to Claus Nielsen)

    by nohandle at 2013-01-21 07:46:34

    Infradeploy:
    Already said it on the first page of the topic viewtopic.php?p=4477#p4477
    [quote="lopyeg"]it seems, i am to young in PoSh)))
    i could not write a function...[/quote]
    Give it some time, I am sure you'll figure it out once you get bit more into PowerShell. 🙂

    by ferry5 at 2013-03-25 22:26:12

    Will it be reliable decision to invest in arizona real estate?
    Luxury Real Estate in Arizona

    by ferry5 at 2013-05-06 20:49:37

    There are lots of ways by which we can increase our property values. Koh samui has already high rated properties.
    http://www.samuiproperty.asia

    by ferry5 at 2013-05-09 23:42:12

    What are the new prices of koh samui property? What did they do to increase their property?
    http://www.samuiproperty.asia

You must be logged in to reply to this topic.