PowerShellScripts
PowerShellScripts copied to clipboard
Passing -Property to Compare-Object
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
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]} ==