You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix the description of the -InputObject parameter for Measure-Command #2140
Specifies objects representing the expressions to be measured.
The actual behavior is as follows:
Objects bound to -InputObject are optional input for the script block passed to -Expression:
Inside the script block, $_ can be used to reference the input object [at hand], as you would in a script block passed to ForEach-Object.
Note: If you use the pipeline to pass multiple input objects, Measure-Command invokes the -ScriptBlock script block once for each input object.
While Measure-Command still times the overall execution (across multiple script-block invocations, if applicable), the overhead from multiple invocations presumably distorts the timings.
Therefore, if feasible, pass the input objects as an (array) argument; e.g.:
That is, the script block is invoked once for each input object, and $_ refers to the object at hand.
Note that this use of -InputObject is a reversal of what makes sense with most other cmdlets, where passing multiple objects only makes sense via the pipeline - see PowerShell/PowerShell#4242.
Activity
Closes MicrosoftDocs#2140 - Fix description of -InputObject parameter…