Skip to content

Compare-Object: -ExcludeDifferent should imply -IncludeEqual #11847

@mklement0

Description

@mklement0

Compare-Object only reports differences by default, requiring explicit opt-in for inclusion of equal objects via -IncludeEqual.

Therefore, the only meaningful behavior when you use -ExcludeDifferent is to default to -IncludeEqual.

Without that, as is currently the case, nothing is ever output, so it is currently effectively pointless to pass -ExcludeDifferent without also passing -IncludeEqual.

Steps to reproduce

Compare-Object 1,2 3, 1 -ExcludeDifferent -PassThru -IncludeEqual  | Should -Be 1
# Currently produces NO output, because -IncludeEqual isn't implied.
Compare-Object 1,2 3, 1 -ExcludeDifferent -PassThru | Should -Be 1

Expected behavior

Both tests should pass.

Actual behavior

The 2nd test fails, because -IncludeEqual is not implied.

Environment data

PowerShell Core 7.0.0-rc.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-FixedThe issue is fixed.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions