PowerShellScripts icon indicating copy to clipboard operation
PowerShellScripts copied to clipboard

Passing -Property to Compare-Object

Open DawidGrzejek opened this issue 2 years ago • 1 comments

Hey,

When passing properties on which objects should be compared actually no difference is made.

$props = @('SN','DN','CN') Compare-Object $1st $2nd -Property $props -IncludeEqual | ft Compare-Object $1st $2nd -IncludeEqual | ft

First and Second compare result in the same output

DawidGrzejek avatar Mar 31 '23 08:03 DawidGrzejek

Hey,

When passing properties on which objects should be compared actually no difference is made.

$props = @('SN','DN','CN') Compare-Object $1st $2nd -Property $props -IncludeEqual | ft Compare-Object $1st $2nd -IncludeEqual | ft

First and Second compare result in the same output

It doesn't work properly on PowerShell 5.1, but even on that, it's not displaying the same result for me:

$1st = @{SN='foo'}
$2nd = @{SN='bar'}
$props = @('SN','DN','CN')
Compare-Object $1st $2nd -Property $props -IncludeEqual | ft
Compare-Object $1st $2nd -IncludeEqual | ft

PowerShell 5.1

SN DN CN SideIndicator
-- -- -- -------------
         ==

InputObject SideIndicator
----------- -------------
{SN}        ==

PowerShell 7.4

SN  DN CN SideIndicator
--  -- -- -------------
bar       =>
foo       <=

InputObject SideIndicator
----------- -------------
{[SN, foo]} ==

God-damnit-all avatar May 14 '24 17:05 God-damnit-all