A Common requirement I’m sure for most businesses is to be able to send a mail to all users who are located in a specific building.
A dynamic distribution group based on the office attribute is surely the answer – well yes it is, but not using the Exchange Management Console.
I have the office attribute set for each user within active directory
However, if you use the exchange management console to build your query, its options are limited and does not include the office attribute.
Although using the EMC it isn’t possible, it can be done in powershell.
The new-dynamicdistributiongroup cmdlet doesn’t natively support anything other than the attributes you see listed in the EMC, however you can use a recipientfilter to specify any attribute you like.
The command below will create a dynamic distribution group called “Users in Example Office name” which will contain any user with the office location set to “Example office Name”
New-DynamicDistributionGroup -Name "Users in Example Office Name" -OrganizationalUnit "domain.net\users" -RecipientFilter { ((RecipientType -eq 'UserMailbox') –and (Office -eq 'Users in example office name')) }
This command can be extended futher using the –and variable. The command below would create the same dynamic distribution group, only the members would be those who are in the “Example office name” building AND their manager is James Bond
New-DynamicDistributionGroup -Name "Users in Example Office Name" -OrganizationalUnit "domain.net\users" -RecipientFilter { ((RecipientType -eq 'UserMailbox') -and (Manager –eq 'James Bond') –and (Office -eq 'Users in example office name')) }