Klaas Vandenberghe notes a discrepancy in how Measure-Object works, based on syntax:
So, is the -InputObject
parameter broken? Not really, but we need to be aware of the logic behind it.
Maybe we are used to work with -ComputerName
for a lot of cmdlets and functions, and we rely blindly upon the ability of the command to handle whatever collection we provide. We know this executes the action we chose, like Get-DbaSqlService
or Get-DbaOperatingSystem
or whatever, separately to every computer in the collection. The collection is ‘fold out’, ‘unpacked’, ‘split’.
-InputObject
doesn’t do that! Is that wrong? Not necessarily, it may be a choice of design to have possibilities to enquire the properties of the collection itself and those of the ‘members’ or ‘children’. It’s just a surprise the behaviour differs from pipeline input to parameter input.
Something to keep in mind when writing Powershell scripts.