Skip to content

Passing -Property to Compare-Object #4

Open

Description

@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

Activity

  1. God-damnit-all commented on May 14, 2024

    @God-damnit-all

    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]} ==
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions