Compare-Object issue

Welcome Forums General PowerShell Q&A Compare-Object issue

This topic contains 1 reply, has 2 voices, and was last updated by

1 year, 11 months ago.

  • Author
  • #69280

    Points: 0
    Rank: Member

    The other day I stumbled over the fact that Compare-Object doesn't handle a Null object very well. This does of course make some sense but, in my case I had to come up with a workaround since the objects being passe to the Compare-Object might very well most of the time be Null objects. I'm comparing AD Group members.. and Compare-Objects side indicator makes this really easy.

    So this is my question, is the solution I'll outline below the "correct" way of solving this issue, or is there a better practice?

    What I did – was I created my own Compare-ObjectADGroupMember function which takes the same two parameters as Compare-Object ReferenceObject and DifferenceObject. I then measure if either of these are Null and if so I assign them a dummy value. At this point neither objects contains a Null vall and I run the regular Compare-Object command. In the end I remove any dummy values from the output of Compare-Object and return that.

    Is this a healthy approach or could it be improved? My function is very ADObject specific

  • #69364

    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    Have you looked at Compare-Object2 in

The topic ‘Compare-Object issue’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort