liveBook · Manning

Parameter binding

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

Pipeline parameter binding byValue is PowerShell's mechanism for binding a pipeline input object to a command parameter based on the input object's type.

Parameter binding byValue connects pipeline commands by comparing the type of each object produced by one command with the parameter types accepted by the next. PowerShell tries ByValue first, then ByPropertyName. Commands receive pipeline data through parameters, so the binding determines where each object goes. section 10.2

Check a proposed ByValue binding in three practical steps:

  • Inspect the incoming object type with Get-Member. section 10.3
  • Read the receiving command’s full help and look for a parameter accepting that type from pipeline ByValue. section 10.3
  • Confirm that the receiving parameter has the meaning you need, not merely a compatible type. section 10.3

Module names through the pipeline

Get-Content ./modules.txt produces System.String objects. Get-Module accepts strings from the pipeline ByValue through its -Name parameter, so this command treats each line as a module name: Get-Content ./modules.txt | Get-Module. A similar pipeline to Get-Command does not meet the goal: its compatible -Name parameter interprets the strings as command names, not module names. section 10.3 section 10.3

When ByValue is unavailable

Get-Process documents -Id as accepting pipeline input ByPropertyName, not ByValue. Likewise, piping strings to New-AzKeyVault fails when no parameter accepts those objects from the pipeline. Use a different command shape or inspect the receiving parameter before assuming a pipeline will work. section 15.3 section 15.3

Get-Content.\modules.txt | Get-Command

Use the concrete pipeline listing to see text-file output flow into a receiving command. section 10.2

PS /Users/tylerl> Get-Command -Module (Get-Content ./modules.txt)

Compare pipeline binding with a parenthetical command, which passes results directly to a parameter instead of relying on pipeline binding. section 10.7

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

How deep it goes
Explains type inspection, help-based verification, semantic mismatches, and ByPropertyName contrast without descending into binding internals.
Examples
Demonstrates module-name files, Get-Module, Get-Command, Get-Process, and New-AzKeyVault.
What it assumes
Assumes basic command and pipeline familiarity while teaching object types and parameter input checks through examples.
What you can do after
Diagnose pipeline failures and choose commands whose parameters accept the incoming object type with the intended meaning.
How it connects
Connects pipeline parameter binding with ByPropertyName, Get-Member, Get-Help, and parenthetical commands.

Also explained in

Compare how 2 books explain parameter binding →

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.