liveBook · Manning

InputObject parameter

As explained in Learn PowerShell Scripting in a Month of Lunches, Second Edition: Write and organize scripts and tools

The InputObject parameter is a command parameter that accepts an input object, including values received from a pipeline.

An InputObject parameter accepts an input object, including pipeline values. Because PSObject is broadly equivalent to .NET’s Object type, a parameter accepting PSObject can receive almost anything. ConvertTo-HTML uses –InputObject to accept objects by value and represent them as HTML. section 4.3

Convert process objects to HTML

Get-Process | ConvertTo-HTML | Out-Null sends each process object to ConvertTo-HTML’s –InputObject parameter. Named and positional arguments bind first, so manually specifying –InputObject would prevent this ByValue binding. section 4.3 section 4.3.2

PS C:\> trace-command -Expression { get-process | convertto-html | 
out-null } -Name ParameterBinding -PSHost 

Trace parameter binding to watch Get-Process, ConvertTo-HTML, and Out-Null bind pipeline objects and generated strings to their InputObject parameters. section 4.3.2

How Learn PowerShell Scripting in a Month of Lunches, Second Edition: Write and organize scripts and tools covers it

How deep it goes
Explains broad object acceptance and traces named, positional, mandatory, and pipeline-binding stages.
Examples
Uses Get-Process piped to ConvertTo-HTML and Out-Null, plus a Trace-Command ParameterBinding diagnostic.
What you can do after
Apply it via ConvertTo-HTML by recognizing when pipeline objects bind automatically to InputObject.
How it connects
Connects parameter binding with the PowerShell pipeline, ByValue binding, PSObject, ConvertTo-HTML, Get-Process, and Out-Null.

This explainer was generated by Manning's knowledge graph from the text of Learn PowerShell Scripting in a Month of Lunches, Second Edition: Write and organize scripts and tools. The section links point to the parts of the book it draws on.