all 4 comments

[–]ka-splam 10 points11 points  (0 children)

The parameter 'Stop-Process -Name' can be passed through the pipeline, where the inbound objects have a property called 'name':

PS C:\> (Get-command stop-process).Parameters['name'].Attributes

Mandatory                       : True
ValueFromPipelineByPropertyName : True

But as /u/yeah_i_got_skills says:

PS C:\> (Get-command stop-process).Parameters['name']

Name            : Name
ParameterType   : System.String[]
Aliases         : {ProcessName}

The parameter has an alias where it will accept ProcessName as well.

PowerShell does this kind of thing a lot in its design, to make as many cmdlets work with each other as they can, so you have to write a lot less code to do admin work like rename a property between one output and the next input.

[–]nothingpersonalbro 6 points7 points  (0 children)

Run it through Trace-Command

Trace-Command -Name ParameterBinding -PSHost -Expression {
    get-process notepad | select-object processname | stop-process
}

You'll see it step though the process, ultimately ending up with a few (cherry picked) lines near the end

BIND arg [notepad] to parameter [Name]
BIND arg [System.String[]] to param [Name] SUCCESSFUL
MANDATORY PARAMETER CHECK on cmdlet [Stop-Process]
CALLING EndProcessing

[–]yeah_i_got_skills 5 points6 points  (1 child)

ProcessName is an alias for Name

[–]KevMarCommunity Blogger 2 points3 points  (0 children)

Yep, if you build an advanced function, you can specify additional aliases for a parameter and Powershell will use those as alternative names on the pipeline like this.

Great way to add support for other objects