Link to home
Start Free TrialLog in
Avatar of ccmhia
ccmhia

asked on

Use ExtensionAttribute to exclude users from Dynamic Distribution group Exch. 2010

I have a dynamic distribution group that includes all Exchange email users but have a few users I don't want in the group.  I want to use extensionAttribute to exclude these users.  What is the powershell command I use to do this?
Avatar of J0rtIT
J0rtIT
Flag of Venezuela, Bolivarian Republic of image

ToAdd
Set-ADUser -Identity "anyUser" -Add @{extensionAttribute4="myString"}

Open in new window

ToRemove
Set-ADUser -Identity "anyUser" -Clear Attribute5LDAPDisplayName, Attribute7LDAPDisplayName

Open in new window

Avatar of ccmhia
ccmhia

ASKER

I'm not wanting how to add the attribute.  I need to have my DynamicDistribution group to exclude a user that has a value in their extensionattribute.  The attribute is populated with "myString"  any user that has that value should not receive emails that are sent to the DynamicDistribution group.
One way is to know what it has all users into a variable with the property "extensionattribute" and then do a foreach (%{}) where you will apply the logic to add/remove from the group.

$AllusersWithProperties= Get-ADUser -filter *   -properties extensionattribute | select * | where{ $_.extensionattribute -eq "Something"}

$AllusersWithProperties | %{
check property value with if block and then add the logic to add or remove
}

Open in new window

Avatar of ccmhia

ASKER

Well I think I'm not explaining what I want to do very well.  I'll give an example. of one I have already that a vendor set up for me and now I want to do a similar thing.  In Exchange I have a Dynamic Distribution Group called :All (company) Email Users".  It includes every user except those users that have the word "physician" in extensionAttribute15. Any email sent to "All (company) Email Users" is delivered to everyone EXCEPT those with the word "physician" in extensionAttribute15 in Active Directory.  When I look at the Recipients filter in the Dynamic Distribution List I see this:

(&(!cn=SystemMailbox{*})(&(&(&(& (mailnickname=*) (| (&(objectCategory=person)(objectClass=user)(|(homeMDB=*)(msExchHomeServerName=*))) )))(objectCategory=user)(!extensionAttribute15=physician))))

I want to recreate this in another Dynamic Distribution Group but want to filter out all users that have the word "Diane" in extensionAttribute1.
ASKER CERTIFIED SOLUTION
Avatar of J0rtIT
J0rtIT
Flag of Venezuela, Bolivarian Republic of image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ccmhia

ASKER

Thank you Thank you Thank you.  Exactly what I was looking for!
Np :)