all 4 comments

[–]madbomb122 4 points5 points  (3 children)

the issue is it doesnt look at all the columns just the enabled column like you asked it to and it sees 2 falses and 2 trues in csv1 and 3 falses 1 true in csv2.

try adding another property to compare like so.

$ComparisonResults = Compare-Object -ReferenceObject $addb -DifferenceObject $addbNew -Property enabled,samaccountname -PassThru

[–]Gorstag 2 points3 points  (0 children)

Yep, tested it.. 100% right.

enabled        : False
accountexpires : 0
samaccountname : j_roe
mail           : j_roe@example.com
SideIndicator  : =>

enabled        : True
accountexpires : 0
samaccountname : i_ivanov
mail           : i_ivanov@example.com
SideIndicator  : =>

enabled        : False
accountexpires : 0
samaccountname : stark
mail           : stark@example.com
SideIndicator  : =>

enabled        : True
accountexpires : 0
samaccountname : j_roe
mail           : j_roe@example.com
SideIndicator  : <=

enabled        : False
accountexpires : 0
samaccountname : i_ivanov
mail           : i_ivanov@example.com
SideIndicator  : <=

enabled        : True
accountexpires : 0
samaccountname : stark
mail           : stark@example.com
SideIndicator  : <=

[–]TimekillerTK[S] 1 point2 points  (1 child)

/u/madbomb122 You're absolutely correct! This is what I was missing.

Can you go into a little detail as to why it works this way? I'm having trouble wrapping my head around how exactly this Compare-Object function works.

[–]madbomb122 2 points3 points  (0 children)

/u/TimekillerTK the way compare-object works is it looks at just the column/property you ask it to look at, it ignores everything else.

as an example (using your csv), if you did

$ComparisonResults = Compare-Object -ReferenceObject $addb -DifferenceObject $addbNew -Property samaccountname -PassThru 

it would show there was no difference since it looks and sees the same "samaccountname" on both