I have two array's having more that 500,000 values and need to compare to find the difference. Some of the values in the array are $null. When I am trying to do the following code and I getting an error Compare-Object : Cannot bind argument to parameter 'ReferenceObject' because it is null
Is there any work around for this issue or is there a better and faster way to find the difference? I am only interested in the count of variance/difference.
Thanks!
Example Code:
$objSource = @('a', $null, 'c')
$objTarget = @('a', 'b','c')
Compare-Object -ReferenceObject $objSource -DifferenceObject $objTarget | Measure
Error Message:
Compare-Object : Cannot bind argument to parameter 'ReferenceObject' because it is null . At line:4 char:32
+ Compare-Object -ReferenceObject <<<< $objSource -DifferenceObject $objTarget
+ CategoryInfo : InvalidData: (:) [Compare-Object], ParameterBindingValid ationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft .PowerShell.Commands.CompareObjectCommand