The following function works:
function myFunc1($arr1)
{
$arr1 | Measure-Object -Maximum
}
myFunc1(@(1,2,3))
But when I add a second parameter, it does not:
function myFunc2($arr1, $arr2)
{
$arr1 | Measure-Object -Maximum
}
myFunc2(@(1,2,3), @(1,2,3))
It gives me this error:
Measure-Object : Cannot compare "System.Object[]" because it is not IComparable.
At C:\Users\bob\Documents\test2.ps1:3 char:13
+ $arr1 | Measure-Object -Maximum
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Measure-Object], PSArgumentException
+ FullyQualifiedErrorId : Argument,Microsoft.PowerShell.Commands.MeasureObjectCommand
All I did was add a send parameter, $arr2
, and it broke the earlier code. I do not understand why the addition of $arr2
would affect calling Measure-Object
on $arr1
.