compare-object question

by Roelstra at 2012-10-29 12:27:07

Hello,

My question is about the compare-object cmdlet but is occurring in the Exchange Online environment. If I posted this to the wrong forum I apologize.

I’m trying to migrate our All User’s group from being statically synced to Exchange Online from our on-premise AD to being a dynamic group hosted in the Exchange Online environment. I’ve done this for a number of our smaller Distribution Groups and it’s worked w/o issue however this group is not cooperating. My process is below

1> Create a dynamic group in Exchange Online that uses the following logic
{(RecipientType -eq 'UserMailbox") -and (RecipientTypeDetails -eq ‘Usermailbox’) -and (CustomAttribute1 -ne ‘Terminated’)}

2> I use the following function to generate a list of the members of the dynamic group

function get-dynamicdistributiongroupmember ($dgname)
{
$DDG = Get-DynamicDistributionGroup $dgname
Get-Recipient -RecipientPreviewFilter $DDG.RecipientFilter
}


3> Compare the membership of the groups using the following command

compare-object $(get-distributiongroupmember "DL_All Associates") ($get-dynamicdistributiongroupmember "DDGTEST") -includeequal

The results tell me that there are a number of users in the dynamic group that are not in the static group however, if I visually compare the membership of the static list to the membership of the dynamic list these users appear in BOTH groups. For example, user Bob appears as

Bob =>

When he should be appearing as

Bob ==

If I output the memberships to two files, selecting just the Display Name property, then run a compare-object against the contents of the files I get results as expected. Bob ==

Any thoughts on why the compare-object cmdlet might be returning what appears to be incorrect results?

Thanks!
by DonJ at 2012-10-30 07:50:20
Compare-Object looks at every property of an object; it’s possible you’ve got some changeable piece of information like a date or something. Add -property name or something like that to have it just consider a specific property or properties in the comparison.