Compare arrays to get those that don’t match

Welcome Forums General PowerShell Q&A Compare arrays to get those that don’t match

  • This topic has 2 replies, 2 voices, and was last updated 7 months ago by
    Participant
    .
Viewing 2 reply threads
  • Author
    Posts
    • #226467
      Participant
      Topics: 52
      Replies: 209
      Points: 873
      Helping Hand
      Rank: Major Contributor

      I’ve two arrays: $Servers and $obj, both contain Node and Instance.

      How can I get the values in $obj that doesn’t exist in $Servers?

      I’ve tried Compare-Object and also tried

      which gives me the exact opposite of what I want, but when I try

      it includes values it should not.

      eg: $Obj

       

      eg: $Servers

    • #226470
      Participant
      Topics: 17
      Replies: 1872
      Points: 3,640
      Helping Hand
      Rank: Community Hero

      I’ve tried Compare-Object and also tried

      Did you specify the properties with Compare-Object?

      Output:

    • #226482
      Participant
      Topics: 52
      Replies: 209
      Points: 873
      Helping Hand
      Rank: Major Contributor

      I hadn’t specified properties, doing so gives the result expected.

      Thanks for your help!

       

Viewing 2 reply threads
  • The topic ‘Compare arrays to get those that don’t match’ is closed to new replies.