Pipeline Deeper

This topic contains 4 replies, has 4 voices, and was last updated by Profile photo of amit aman amit aman 2 months, 3 weeks ago.

  • Author
    Posts
  • #54033
    Profile photo of amit aman
    amit aman
    Participant

    Hi team,

    I am struggling with one concept. Kindly let me know what exactly is the meaning of:
    Accept pipeline input? true(ByValue,ByPropertyName)

    My understanding about it is Name parameter can only accept the pipeline input if both conditions i.e. ByValue and ByPropertyName are satisfied.

    -InputObject
    Specifies ServiceController objects that represent the services to stop. Enter a variable that contains the
    objects, or type a command or expression that gets the objects.

    Required? true
    Position? 1
    Default value none
    Accept pipeline input? True (ByValue)
    Accept wildcard characters? false

    -Name
    Specifies the service names of the services to stop. Wildcard characters are permitted.

    Required? true
    Position? 1
    Default value none
    Accept pipeline input? true(ByValue,ByPropertyName)
    Accept wildcard characters? false

    This concept was explained by Jeffery and Jason in JumpStart video. But I think I am lagging with some concept here.
    Kindly explain.

  • #54037
    Profile photo of Hermann Lüpfert
    Hermann Lüpfert
    Participant

    Hi Amit,

    could you explain: what exactly is the question?
    ServiceController objects have a -Name parameter which accepts pipeline input ByValue or ByPropertyName.

    The method ByValue should be called ByType...

  • #54038
    Profile photo of Craig Duff
    Craig Duff
    Participant

    ByValue means that you are piping an object or value directly to that one parameter. ByPropertyName means you can pass an object that has properties that match those parameters to one or more parameters. When they both appear it means you can either pass by value or pass by property name. They are exclusive.

    In this case you can pipe it a ServiceController object and it would get assigned to InputObject, or you could pass it a string that has the name of the service and it would get assigned to the Name parameter. Another option would be to pass it a custom built object with column headers that matched Name and any other ByPropertyName parameter and it would fill out all those parameters.

    I suppose you are looking at Get-Service, in which case you pass the name attribute byvalue like:

    "wuauserv" | Get-Service

    Or say you had a csv with the column headers Name and ComputerName, you can specify both of those properties bypropertyname like:

    Import-Csv c:\mylist.csv | Get-Service
  • #54039
    Profile photo of Don Jones
    Don Jones
    Keymaster

    If you read "Learn PowerShell in a Month of Lunches," you'll find an entire chapter explaining what that means. But, youtube.com/powershelldon has the companion videos from the book, and there's a couple on exactly this question.

  • #54083
    Profile photo of amit aman
    amit aman
    Participant

    Thanks Don and Craig for the response. Was a bit confused about parameter sets and that's why I was having trouble in understanding the syntax. Now very much clear about them. 🙂

You must be logged in to reply to this topic.