Dynamic distribution group in Exchange 2010 with 6 sub domains

Hi Guys
I really need some help here ?

I have Exchange 2010 Setup running with Windows server 2008

There is a root domain with 6 sub domains
Sub domains are located in different countries

My Boss wants me to create a dynamic distribution group where all users from entire Exchange origination ,with mail enabled mailbox ,have to be member of this dynamic distribution. But consulted user has to be excluded.

He want me to do it easiest way. Like Power Shell

The big question, how can I do that?

Is it possible to make a Power shell cmdlet  

Remember users /mailboxes are locate in the 6 sub domains , some users /mailboxes are in the root domain
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

Hilal1924Connect With a Mentor Commented:
You need to add this attribute to your user. It is called a Custom Attribute. Or if your users have a unique attribute which your consultants don't have, then you can use that attribute as well. For Example your users might have an office location  associated with their account while as Consultants might not have this information and there is how you can filter them.

Here is an Example:
new-DynamicDistributionGroup testdist2 -RecipientContainer "OU=Employees,DC=Playlsi,DC=com" -OrganizationalUnit "OU=Mail Distribution Groups,DC=Playlsi,DC=com" -RecipientFilter {((RecipientType -eq 'UserMailbox')-and -not (Name -like '*room*'))}

More Information:



Here is how you should proceed:

Add a unique custom attribute to rest of the users (Excluding Consultants) and include that attribute for creating the DD Group.

You can add the attribute with this Command:
Get-Mailbox | Set-Mailbox -CustomAttribute1 "any attribute you like"

Powershell command to Create Dynamic Distribution group:

New-DynamicDistributionGroup -Name <group name> -RecipientFilter {<custom filter attribute conditions>}
johnfreakAuthor Commented:


thanks for the answer :)

I have now try it on my test exchange 2007
Get-Mailbox | Set-Mailbox -CustomAttribute1 "test attribute"

where do I find the attribute "test attribute"on user account in AD users and Computers ?

and when I run the powerhell command Get-Mailbox | Set-Mailbox -CustomAttribute1 "test attribute"
 how can I Excluding Consultants? with the powerhell command I hit all users with mailbox  right ?

New-DynamicDistributionGroup -Name <group name> -RecipientFilter {<custom filter attribute conditions>what do I type here the attribute name ? } ?

How can all theese users with CustomAttribute1 "test attribute" be member of my New-DynamicDistributionGroup ?

Please help ?

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

johnfreakAuthor Commented:
Thanks a lot for the answer

its it possible you can make me a powershell comand ,

where I get all mailboxes , and make them member of the new-DynamicDistributionGroup but all
users who is member of the Consultants group should not be member of this new-DynamicDistributionGroup

Is that possible to exclude a member of group ?

Hope you understand what I mean ? :)

My boss dont like the attribute  idea Sorry :( long story

johnfreakAuthor Commented:

As I can see now the consult have no member of group which is in common

Only thing there is in common in all sub domains is the are in a OU alle same named Consultants
any idea whats the best solution could be .

Mayby some how with powershell field out the description field with name consult and then exclude the

description field , ( any user who has consult in description field have to be excluded)

What do you think
johnfreakAuthor Commented:
I did assosiate with the Company name .

It works now

( any user who has consult in description field have to be excluded)

Looks good to me. But Custom Attributes would have been much better. Let me know if you would want me to write a script for you for filtering based on Description.

All Courses

From novice to tech pro — start learning today.