Dynamic Dist List Creation (with Wildcard)
		
	I'm trying to make a dynamic list using Custom Attributes (which requires -IncludedRecipients), but need it to work with wildcards (or some other method). When using -RecipiantFilter wildcards work, which allows more then one item in the non-Custom Attribute
 field, i.e. Description, Title, etc.
We need to move the filter items to the Custom Attributes fields and since someone may have multiple items, say being a part-time contractor in the UK, we'd have (PT) (CON) (UK).
The first script creates a dynamic list, but it only works when there's one item in the Custom Attribute field. As soon as a second item is
 added that person is dropped from the list. The second script is a sample of what we were using before to filter on Department, which used wildcards successfully.
Any thoughts or ideas would be greatly appreciated.
   Tom
New-DynamicDistributionGroup -Name
"ZDL-TEST"
 -Alias "ZDL-TEST"
 -IncludedRecipients "MailboxUsers"
 -OrganizationalUnit "contoso.com/Contoso
 Users" -ConditionalCustomAttribute2
"(UK)"
 -RecipientContainer "contoso.com/Contoso
 Users"
 
New-DynamicDistributionGroup -Name
 
"ZDL-TEST"
 -Alias "ZDL-TEST"
 -OrganizationalUnit "contoso.com/Contoso
 Users/Groups" -RecipientFilter {(RecipientType
-eq
'UserMailbox')
-and
 (Department -like
'*(UK)*')}
 –RecipientContainer "contoso.com/Contoso
 Users"		
				March 31st, 2011 8:22pm
			On Fri, 1 Apr 2011 00:15:03 +0000, Meltivore wrote:
 
>
>
>I'm trying to make a dynamic list using Custom Attributes (which requires -IncludedRecipients), but need it to work with wildcards (or some other method). When using -RecipiantFilter wildcards work, which allows more then one item in the non-Custom Attribute
 field, i.e. Description, Title, etc. 
>
>We need to move the filter items to the Custom Attributes fields and since someone may have multiple items, say being a part-time contractor in the UK, we'd have (PT) (CON) (UK).
>
>The first script creates a dynamic list, but it only works when there's one item in the Custom Attribute field. As soon as a second item is added that person is dropped from the list. The second script is a sample of what we were using before to filter
 on Department, which used wildcards successfully. 
>
>Any thoughts or ideas would be greatly appreciated. 
>
> Tom 
>
>New-DynamicDistributionGroup -Name 
>
>"ZDL-TEST" -Alias "ZDL-TEST" -IncludedRecipients "MailboxUsers" -OrganizationalUnit "contoso.com/Contoso Users" -ConditionalCustomAttribute2 "(UK)" -RecipientContainer "contoso.com/Contoso Users"
>
> 
>
>New-DynamicDistributionGroup -Name 
>
> "ZDL-TEST" -Alias "ZDL-TEST" -OrganizationalUnit "contoso.com/Contoso Users/Groups" -RecipientFilter {(RecipientType -eq 'UserMailbox') -and (Department -like '*(UK)*')} ?RecipientContainer "contoso.com/Contoso Users"
 
Is there a question here? 
 
Are you asking if "... -and CustomAttribute2 -like '*(UK)*'" will
work? It will.
 
If you have a problem how about some details?
 
---
Rich Matheisen
MCSE+I, Exchange MVP
 --- Rich Matheisen MCSE+I, Exchange MVP		
				Free Windows Admin Tool Kit Click here and download it now
					March 31st, 2011 10:26pm
			Thanks, I'll give that a try tomorrow.
Somehow you seemed to figure it out without me having to add a question mark or more details :)		
				March 31st, 2011 10:34pm
			I was hoping for the best, but changing to -like '*(UK)*' didn't work (see below). When I leave out -like and just use "*(UK)*", it treats the asterisks as actual characters for the filter.
So how can I create a dynamic dist group that will reference a single ConditionalCustomAttribute value, even though there may be multiple items, i.e. (PT) (CON) (UK)?
New-DynamicDistributionGroup : A positional parameter cannot be found that acce
pts argument '*(UK)*'.
At C:\Scripts\DLCreation.ps1:1 char:29
+ New-DynamicDistributionGroup <<<<  -Name "ZDL-TEST2" -Alias "ZDL-TEST2" -Incl
udedRecipients "MailboxUsers" -OrganizationalUnit "contoso.com/Contoso Users"
 -ConditionalCustomAttribute2 -like '*(UK)*' -RecipientContainer "contoso.com/
Contoso Users"
    + CategoryInfo          : InvalidArgument: (:) [New-DynamicDistributionGro
   up], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.Exchange.M
   anagement.RecipientTasks.NewDynamicDistributionGroup		
				Free Windows Admin Tool Kit Click here and download it now
					April 1st, 2011 6:01pm
			Hi Meltivore,
Per my known, we could not use the format like "-ConditionalCustomAttribute2 -like '*(UK)*'", that means, when we use the
 parameter "conditioncustomattribute", we should set it as a specual identity.
So,  if you want to use the cnditionalcustomeattribute to filter the mailbox, I would suggest that your could use the parameter "recipientfilter".
Such as:
... -recipientfilter {(customeattribute2 -like "*(UK)*") and ...}
Regards!
GavinPlease remember to click Mark as Answer on the post that helps you, and to click Unmark as Answer if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.		
				April 4th, 2011 1:39am
			Hi Gavin,
 I have a feeling (based on the EMC view and numerous syntax attempts) that the -ConditionalCustomAttribute does not support wildcards.
 MS documentation states that you can't use -ConditionalCustomAttribute with -recipientfilter, but must use -IncludedRecipients:
http://technet.microsoft.com/en-us/library/bb125127(EXCHG.80).aspx
 
  Thanks for the info.
    Tom		
				Free Windows Admin Tool Kit Click here and download it now
					April 4th, 2011 5:51pm
			Hi Tom,
Sure, what I mean, if we want to use the wildcard, we must use the parameter recipientfilter; and at the time, we could not use the includedrecipients.
In other other words, we could achieve your target through other ways by using different parameter.
Good luck!
Regards!
Gavin
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.		
				April 4th, 2011 9:36pm
			On Fri, 1 Apr 2011 21:54:57 +0000, Meltivore wrote:
 
>I was hoping for the best, but changing to -like '*(UK)*' didn't work (see below). When I leave out -like and just use "*(UK)*", it treats the asterisks as actual characters for the filter.
 
You can't use the parameter "-customattribute2", you have to use a
filter and place the condition in the filter.
 
This was the example in my previous answer:
 
New-DynamicDistributionGroup -Name "ZDL-TEST" -Alias "ZDL-TEST"
-OrganizationalUnit "contoso.com/Contoso Users/Groups"
-RecipientFilter {(RecipientType -eq 'UserMailbox') -and (Department
-like '*(UK)*')} ?RecipientContainer "contoso.com/Contoso Users"
 
 
You seem to have changed your original attempt to use a different set
of parameters.
 
>So how can I create a dynamic dist group that will reference a single ConditionalCustomAttribute value, even though there may be multiple items, i.e. (PT) (CON) (UK)?
 
Reread my previous answer, or use the code above. If the '*(UK)*'
doesn't work, trplace the "'" with '"' (e.g. "*(UK)*").
 
---
Rich Matheisen
MCSE+I, Exchange MVP
 --- Rich Matheisen MCSE+I, Exchange MVP		
				Free Windows Admin Tool Kit Click here and download it now
					April 4th, 2011 10:08pm
			Hi Rich,
 In my original post I stated we needed to move the filter items to the Custom Attributes fields, which don't allow using -RecipientFilter or seemingly, wildcards; so my parameters are still the same.
 We have no problem when using multiple entries in the Departments field (as in your example, and my first post), it was just when we tried to use the ConditionalCustomAttribute field for filtering that the wildcard failed.
    Thanks,
          Tom		
				April 5th, 2011 6:12pm
			Hi Tom,
Per my known, we could not use the wildcard when we use the conditionalcustomattribute parameter.
If we check it through the EMC, we will found that there is a operator "equals".
Regards!
GavinPlease remember to click Mark as Answer on the post that helps you, and to click Unmark as Answer if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.		
				Free Windows Admin Tool Kit Click here and download it now
					April 5th, 2011 9:57pm
			On Tue, 5 Apr 2011 21:57:14 +0000, Meltivore wrote:
 
> In my original post I stated we needed to move the filter items to the Custom Attributes fields, which don't allow using -RecipientFilter or seemingly, wildcards; so my parameters are still the same.
>
> We have no problem when using multiple entries in the Departments field (as in your example, and my first post), it was just when we tried to use the ConditionalCustomAttribute field for filtering that the wildcard failed.
 
I just used this to create a DDL:
 
New-DynamicDistributionGroup -Name "ZDL-TEST" -Alias "ZDL-TEST"
-RecipientFilter {(RecipientType -eq "UserMailbox") -and
(CustomAttribute2 -like "*(UK)*")}
 
I don't understand why you're saying you can't be used in a recipient
filter.
 
I put stuff like this ("NYC (US);London (UK)") into CA2 on a couple of
mailboxes and it all worked.
 
---
Rich Matheisen
MCSE+I, Exchange MVP
 --- Rich Matheisen MCSE+I, Exchange MVP		
				April 5th, 2011 10:21pm
			Hi Rich,
 That was it, thx! We were down the wrong path thinking we need to use
ConditionalCustomAttribute.
   Cheers!
          Tom		
				Free Windows Admin Tool Kit Click here and download it now
					April 6th, 2011 6:36pm
			

