Updating from O365GroupSync DisplayName filtering to CustomAttribute filtering

As of GroupSync v0.56, filtering on a custom attribute is now possible.

If you want to switch to this mode, but are already using displayName filtering, you’ll have to first set the custom attribute on both sides (office 365, local AD).

Here’s a simple example of how to do so in Exchange Online:

$distributionGroups = get-DistributionGroup -resultsize unlimited
$distributionGroupsToRename = $distributionGroups | where {$_.DisplayName -like "NL -*"}
$distributionGroupsToRename | set-distributiongroup -CustomAttribute2 "NLD" -BypassSecurityGroupManagerCheck

And here in how to do so in the local AD:

ipmo activedirectory
$groups = Get-ADGroup -Filter {mail -like "*"} -Properties * -SearchBase "OU=Distribution Lists,OU=Groups,OU=0 Generic,DC=XXXX,DC=LOCAL" -SearchScope Subtree -ErrorAction Stop
$groupsToRename = $groups | where {$_.DisplayName -like "NL - *"}
$groupsToRename | Set-ADGroup -Replace @{'extensionAttribute2'="NLD"} -ErrorAction Stop

Don’t forget to set these parameters before you run O365GroupSync v0.56:
$cloudCustomAttributeValue = “”
$localCustomAttributeValue = “”

Microsoft 365, Azure, Automation & Code