liveBook · Manning

Pipeline parameter binding bypropertyname

As explained in Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS

Pipeline parameter binding byPropertyName is PowerShell's mechanism for binding a pipeline input object's property value to a command parameter with a matching name.

When one PowerShell command sends objects to another, the receiving command must place each object on a parameter. Pipeline parameter binding is the process PowerShell uses to make that connection. If ByValue cannot bind the object itself, PowerShell tries ByPropertyName: it looks for input-object properties whose names match command-parameter names. section 10.2 section 10.3

Use this quick method to check whether property-name binding will work:

  • Inspect the input objects with Get-Member and note their property names. section 10.4
  • Inspect the receiving command's full help and find parameters marked “Accept pipeline input: True (ByPropertyName).” section 10.4 section 15.3
  • Match spelling exactly: a property named Name can bind to a parameter named -Name. section 10.4
  • Remember that every matching property and eligible parameter may bind, not just one pair. section 10.4
  • Check the values as well as the names; a successful name match can still pass unusable data. section 10.4

Renaming imported data for New-ADUser

An HR CSV might contain login and dept instead of the properties required by New-ADUser. Add calculated properties, then pipe the corrected objects onward: Import-Csv .\newusers.csv | Select-Object -Property *, @{Name='samAccountName'; Expression={$_.login}}, @{Name='Name'; Expression={$_.login}}, @{Name='Department'; Expression={$_.Dept}} | New-ADUser Select-Object preserves the existing properties and adds names that match New-ADUser parameters. This replaces repeated manual CSV editing with a repeatable transformation. section 10.5

How Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS covers it

How deep it goes
Explains matching, help verification, multiple bindings, bad values, and property renaming, but stops short of scripting-language internals.
Examples
Demonstrates Get-ChildItem to Stop-Process, Import-Csv to New-Alias, and renamed CSV properties piped to New-ADUser.
What it assumes
Assumes basic pipelines and commands, while teaching binding checks and property reshaping through concrete administrative tasks.
What you can do after
Diagnose binding failures with Get-Member and full help, then reshape objects so eligible parameters receive matching properties.
How it connects
Ties pipeline parameter binding to ByValue, command parameters, object properties, Get-Member, Import-Csv, and Select-Object.

Also explained in

Compare how 2 books explain pipeline parameter binding bypropertyname →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS. The section links point to the parts of the book it draws on.