1

I have a new admin on our team, and she is having some permissions issues. Some things the new admin runs in Exchange PowerShell are giving weird errors that the rest of the team doesn't get, and google doesn't help with figuring out what those errors mean. So we figure it must be a permissions issue. In my investigation, I ran a query of the new admin's group membership, and then I wanted to compare it against mine. Everything seemed to work, however, I noticed the compare-object command didn't find all the differences when I spot checked the results.

Here is what I ran:

$a = Get-ADPrincipalGroupMembership "me" | select name

$b = Get-ADPrincipalGroupMembership "new admin" | select name

Compare-Object $a $b | ft -AutoSize

It listed about 7 results, but right away I noticed that I was in one group that started with an "A" and she wasn't in that group, and it was not listed in the results. Any suggestions?

3
  • 1
    Was that a primary group by chance? Shot in the dark since we cannot see the data. If you manually compare the two lists do you get the same results? We don't know where you made those comparisons. Commented Jul 8, 2015 at 17:50
  • 1
    Try changing it to | Select -ExpandProperty Name and see if that works better for you Commented Jul 8, 2015 at 18:28
  • @TheMadTechnician I didnt think it would matter but that is the issue I bet now. I just tested and got different results. the -Property parameter of compare-object would also work Commented Jul 8, 2015 at 18:53

1 Answer 1

2

Compare-Object was comparing two objects with Name properties. Still not completely sure why but the comparison is done better, in this case, with just straight strings. There are object based technet examples which is why I did't immediately assume it was related.

$a = Get-ADPrincipalGroupMembership "me" | select -expandProperty name
$b = Get-ADPrincipalGroupMembership "new admin" | select -expandProperty name

Compare-Object $a $b | ft -AutoSize

Or you could have used the -Property parameter of compare-object as well.

$a = Get-ADPrincipalGroupMembership "me" 
$b = Get-ADPrincipalGroupMembership "new admin"

Compare-Object $a $b -Property Name | ft -AutoSize
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.