Solved

Address lists in Exchange 2010 with multiple CustomAttributes

Posted on 2011-09-19
10
1,307 Views
Last Modified: 2012-05-12
Exchange 2010 SP1 RU5

I am trying to make dynamic address book lists according to Custom Attributes. I have some teachers that teach at different schools and they need to be put in address books which are set up for each school. I populated extensionAtrributes in AD with school locations which a teacher belongs to according to Human Resources. Then I made an address list with Custom Attributes set to multiple locations like this:

new-AddressList -Name 'test-fremont' -RecipientContainer 'sdw.ad/SCHOOLS' -IncludedRecipients 'AllRecipients' -ConditionalCustomAttribute2 '706' -ConditionalCustomAttribute3 '706' -Container '\Schools' -DisplayName 'test-school'

My AD extensionAttributes:

extensionAttribute 2 = 701  ==> Custom Attribute 2

extensionAttribute 3 = 706  ==> Custom Attribute 3

My problem is that I can't use (or don't know how to) multiple CustomAttributes as an 'OR' statement. In my statement above it command tries to meet all requirements. So if I have a teacher with multiple extensionAttributes in AD, I can't just pick one Custom Attribute. I was hoping to use an -OR statement in the new-AddressList command to populate those lists. Is there a way to use the -OR or is there a better way to create address lists and look at different Custom Attributes for location?

Thanks, Alex
0
Comment
Question by:akorkishko
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 2
10 Comments
 
LVL 7

Expert Comment

by:brota
ID: 36561823
from this article you can use -or

•Powershell uses "-and", "-or", and "-not" (yes, with leading hyphen)


http://blogs.technet.com/b/exchange/archive/2007/01/10/3397707.aspx

Some good examples of -or
http://technet.microsoft.com/en-us/library/cc164375.aspx
0
 
LVL 12

Expert Comment

by:FDiskWizard
ID: 36561836
Try it this way:

Replace:  -ConditionalCustomAttribute2 '706' -ConditionalCustomAttribute3 '706'
With:        -RecipientFilter {(ExtensionAttribute2 -eq "701") -OR (ExtensionAttribute3 -eq "706")}

Have not tested. But I think that should do it.
0
 

Author Comment

by:akorkishko
ID: 36561924
Thanks for replies guys.

FDISKWizard, I have tried your recommendation and this is what I got:

[PS] C:\Windows\system32>new-AddressList -Name 'test-1' -RecipientContainer 'wsd.ad/SCHOOLS' -IncludedRecipients 'AllRec
ipients' -RecipientFilter {(ExtensionAttribute2 -eq "701") -OR (ExtensionAttribute3 -eq "706")} -Container '\Schools' -D
isplayName 'test-school'
Parameter set cannot be resolved using the specified named parameters.
    + CategoryInfo          : InvalidArgument: (:) [New-AddressList], ParameterBindingException
    + FullyQualifiedErrorId : AmbiguousParameterSet,New-AddressList

Any clues?
0
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
LVL 7

Expert Comment

by:brota
ID: 36562042
try this

-RecipientFilter {(RecipientType -eq 'UserMailbox') -and (ExtensionAttribute2 -eq "701")  -or  (ExtensionAttribute3 -eq "706")}
0
 

Author Comment

by:akorkishko
ID: 36562192
Same error:

[PS] C:\Windows\system32>New-AddressList -Name 'test-1' -RecipientContainer 'wsd.ad\Schools' -IncludedRecipients 'AllRecipients' -RecipientFilter {(RecipientType -eq 'UserMailbox') -and (ExtensionAttribute -eq "701") -or (ExtensionAttribute -eq "706")} -Container '\Schools' -DisplayName 'test-1'

Parameter set cannot be resolved using the specified named parameters.
    + CategoryInfo          : InvalidArgument: (:) [New-AddressList], ParameterBindingException
    + FullyQualifiedErrorId : AmbiguousParameterSet,New-AddressList

Thanks again for the help.
0
 
LVL 7

Accepted Solution

by:
brota earned 250 total points
ID: 36562219
try taking out 'AllRecipients'
0
 
LVL 12

Assisted Solution

by:FDiskWizard
FDiskWizard earned 250 total points
ID: 36562577
Yeah... I don't think you can mix the -IncludedRecipients  and -RecipientFilter together.
So, take out the whole "IncludedRecipients 'AllRecipients'" part.
0
 

Author Comment

by:akorkishko
ID: 36562765
Thanks guys, figured it out. You had me on the right path. I had to replace extensionAttribute with CustomAttribute, I guess Exchange doesn't see 'extensionAttribute' from AD.

My final command looks like this, in case someone else runs into this:

[PS] C:\Windows\system32>New-AddressList -Name 'test-1' -RecipientContainer 'wsd.ad' -RecipientFilter {(CustomAttribute2 -eq "701") -or (CustomAttribute3 -eq "706")} -Container '\Schools' -DisplayName 'test-1'

Since both of you helped me, can I give points to both of you?
0
 
LVL 7

Expert Comment

by:brota
ID: 36562778
yes the points can be split

0
 

Author Closing Comment

by:akorkishko
ID: 36562786
I added my own solution for others to see the correct syntax
0

Featured Post

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Read this checklist to learn more about the 15 things you should never include in an email signature.
In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
In this video we show how to create a Distribution Group in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Recipients >>…
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question