Pipeline Deeper

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.

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…

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

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.

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. :slight_smile: