Hi Guys,
You probably already met with a similar problem in your organization. Communications Department has dozens of distribution groups, that need to be updtaed base on some mechanism. In my organization we use attribute office and country. My current code looks like this
For demonstration purposes let's say I have just 4 groups, in "real world" we have more then 20 ones.
Import-Module Adaxes
$EveryoneEastUS = "Everyone East US"
$EveryoneWestUS = "Everyone West US"
$EvetyoneEastUK = "Everyone West US"
$EvetyoneWestUK = "Everyone West US"
In this place I just repet below model for all groups
# Get all current group members of the "Everyone East US"
$group = Get-AdmGroup $EveryoneEastUS -AdaxesService $admService -Properties member
$members = $group.member
if ($members)
{
# Remove old users from the group
Remove-AdmGroupMember $EveryoneEastUS -Members $members -Confirm:$false -AdaxesService $admService
}
# Add new group members to the "Everyone East US"
Get-AdmUser -LDAPFilter '(&(objectClass=user)(&(physicalDeliveryOfficeName=East)(c=US)))' | Foreach-object {Add-AdmGroupMember $EveryoneEastUS -Confirm:$false -AdaxesService $admService -Member $_.DistinguishedName}
Main problem that in each group, there are several thousand of users and my script need a lot of time to do the job.
Maybe you can share some better solution to achieve same goal.