Comparing two arrays & get the values which are not common

i wanted a small logic to compare contents of two arrays & get the value which is not common amongst them using powershell

example if


$c which is the output should give me the value "6" which is the output of what's the uncommon value between both the arrays.

Can some one help me out with the same! thanks!


  • PS > $c = Compare-Object -ReferenceObject (1..5) -DifferenceObject (1..6) -PassThru
    PS > $c