New-DynamicDistributionGroup - Issue filtering on EmailAddresses
Hi, I'm trying to create a Dynamic Distribution Group with Powershell and filter out members with a certain domain in thier smtp address. The command I have been using is: New-DynamicDistributionGroup -Name "All ABCD Group Users" -Alias "AllABCDGroupUsers" -OrganizationalUnit "abc.abcgrp.net/Central/Distribution Groups" -RecipientFilter {((RecipientType -eq 'UserMailbox') -and (Email Addresses -notlike 'smtp:*@abcdefgsupport.co.uk'))} -RecipientContainer "abc.abcgrp.net/Business Units" The error points to the operator '-notlike'. I've tried using -ne, -eq, -like just to see if they work but with the same out come. The error I recieve is; New-DynamicDistributionGroup : Cannot bind parameter 'RecipientFilter' to the target. Exception setting "RecipientFilte r": """ is not a valid operator. For a list of supported operators see the command help. "((RecipientType -eq 'UserMailbox') -and (EmailAddresses -notlike 'smtp:*@abcdefgsupport.co.uk'))" at position 57." At line:1 char:168 + New-DynamicDistributionGroup -Name "All ABCD Group Users" -Alias "AllABCDGroupUsers" -OrganizationalUnit "abc.hydegrp .net/Central/Distribution Groups" -RecipientFilter <<<< {((RecipientType -eq 'UserMailbox') -and (EmailAddresses -notl ike 'smtp:*@abcdefgsupport.co.uk'))} -RecipientContainer "abc.hydegrp.net/Business Units" Documentation states that EmailAddresses can be used with -RecipientFilter, just can't see what I'm doing wrong. Any suggestions appreciated. Cheers
December 29th, 2011 6:11pm

Your syntax works on my Exchange 2010 SP1 RU2 lab (yes, I've been lax in my updates!), but I did have to change your -OrganizationalUnit and -RecipientContainer values to something that works in my test domain. You might want to check the -RecipientContainer value since that does get combined with the -RecipientFilter to form a complete query.Ed Crowley MVP "There are seldom good technological solutions to behavioral problems."
Free Windows Admin Tool Kit Click here and download it now
December 29th, 2011 9:43pm

Hi Mark, Which version of Exchange server do you use? create a Dynamic Distribution Group with Powershell and filter out members with a certain domain(@bb.com) in thier smtp address Do you mean: UserA: SMTP: UserA@aa.com UserB: SMTP: UserB@bb.com UserC: SMTP: UserC@aa.com, smtp:UserC@bb.com The DDG will contain UserA AND UserB ? By the way, the cmdlet you provided works in my test lab(Exchange 2010 SP2). Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.Frank Wang TechNet Community Support
December 30th, 2011 3:47am

Ed, Frank, Thank you for your replies. Apologies I should have included details of Exchange version in the post. I am still running 2007 SP2. The documnetation I've been following is for this version so hopefully not being on 2010 isn't the problem. Ed, I've checked the RecipientContainer and can see nothing amiss. I tried taking out the EmailAddress criteria and running with just RecipientType and it work okay. Frank, looking at your example I would only expect UserA to be included in the group. Both B & C have addresses ending @bb.com which should be filtered out.
Free Windows Admin Tool Kit Click here and download it now
December 30th, 2011 4:31am

I don't have an Exchange 2007 server in my lab on which to test your command, sorry.Ed Crowley MVP "There are seldom good technological solutions to behavioral problems."
December 30th, 2011 1:08pm

On Thu, 29 Dec 2011 23:11:58 +0000, Mark S Dale wrote: > > >Hi, > >I'm trying to create a Dynamic Distribution Group with Powershell and filter out members with a certain domain in thier smtp address. > >The command I have been using is: > >New-DynamicDistributionGroup -Name "All ABCD Group Users" -Alias "AllABCDGroupUsers" -OrganizationalUnit "abc.abcgrp.net/Central/Distribution Groups" -RecipientFilter {((RecipientType -eq 'UserMailbox') -and (Email Addresses -notlike 'smtp:*@abcdefgsupport.co.uk'))} -RecipientContainer "abc.abcgrp.net/Business Units" > >The error points to the operator '-notlike'. I've tried using -ne, -eq, -like just to see if they work but with the same out come. The error I recieve is; > >New-DynamicDistributionGroup : Cannot bind parameter 'RecipientFilter' to the target. Exception setting "RecipientFilte r": """ is not a valid operator. For a list of supported operators see the command help. "((RecipientType -eq 'UserMailbox') -and (EmailAddresses -notlike 'smtp:*@abcdefgsupport.co.uk'))" at position 57." At line:1 char:168 + New-DynamicDistributionGroup -Name "All ABCD Group Users" -Alias "AllABCDGroupUsers" -OrganizationalUnit "abc.hydegrp net/Central/Distribution Groups" -RecipientFilter <<<< {((RecipientType -eq 'UserMailbox') -and (EmailAddresses -notl ike 'smtp:*@abcdefgsupport.co.uk'))} -RecipientContainer "abc.hydegrp.net/Business Units" > > > >Documentation states that EmailAddresses can be used with -RecipientFilter, just can't see what I'm doing wrong. Well, spelling "EmailAddresses" as "Email<space>Addresses" doesn't help. ;-) Other than that, your example (when I run it with "-whatif") seems to work okay. --- Rich Matheisen MCSE+I, Exchange MVP --- Rich Matheisen MCSE+I, Exchange MVP
Free Windows Admin Tool Kit Click here and download it now
December 30th, 2011 3:50pm

It wouldn't be the first time I've had code where a stray space has broken it... but not this time... unfortunlately. Seems to work fine for everyone except me. Are you using 2007 SP2 Rich? Thanks all for your efforts so far. Looks like I've got a weekend of scratching my head.
December 30th, 2011 4:48pm

On Fri, 30 Dec 2011 21:48:42 +0000, Mark S Dale wrote: > > >It wouldn't be the first time I've had code where a stray space has broken it... but not this time... unfortunlately. Does that mean you didn't have the <space> character in the middle of "EmailAddresses"? Or that you did and you removed it and you still had the same problem? I think I'd select the "EmailAddresses" string in that cmdlet, delete it, and reenter it. I've seen weird characters in strings before that that don't act the same in a text editor as they do in a HTML page. >Seems to work fine for everyone except me. > >Are you using 2007 SP2 Rich? 2007 SP3 UR4 is on the machine I tried it on. Here's the cmdlet I ran: New-DynamicDistributionGroup -Name "All ABCD Group Users" -Alias "AllABCDGroupUsers" -OrganizationalUnit "abc.abcgrp.net/Central/Distribution Groups" -RecipientFilter {((RecipientType -eq 'UserMailbox') -and (EmailAddresses -notlike 'smtp:*@abcdefgsupport.co.uk'))} -RecipientContainer "abc.abcgrp.net/Business Units" -Whatif Just for grins and giggles, I removed the organization-specific stuff and ran this (without the "-whatif") and it ran successfully: New-DynamicDistributionGroup -Name "All ABCD Group Users" -Alias "AllABCDGroupUsers" -RecipientFilter {((RecipientType -eq 'UserMailbox') -and (EmailAddresses -notlike 'smtp:*@abcdefgsupport.co.uk'))} --- Rich Matheisen MCSE+I, Exchange MVP --- Rich Matheisen MCSE+I, Exchange MVP
Free Windows Admin Tool Kit Click here and download it now
December 30th, 2011 5:09pm

I didn't have the space in there. Which is odd as I did just cut and paste into the forum. I did then take out some company specific stuff then so could have been when it happened. I'll remove and re-add in my editor as you suggest. Open to any ideas right now! Notice you're on a later SP too which maybe relevant. I'll keep digging. Cheers
December 30th, 2011 5:27pm

New-DynamicDistributionGroup -Name "All ABCD Group Users" -Alias "AllABCDGroupUsers" -OrganizationalUnit "abc.abcgrp.net/Central/Distribution Groups" -RecipientFilter {((RecipientType -eq 'UserMailbox') -and (Email Addresses -notlike 'smtp:*@abcdefgsupport.co.uk'))} -RecipientContainer "abc.abcgrp.net/Business Units" Hi Mark, I test your orginal cmdlet in my Exchange 2007 SP2 lab. And it works. But the result is not excepted. Please use EmailAddresses -notlike '*@abcdefgsupport.co.uk' After you finish creating the DDG, please don't use EMC to preview the members of DDG. Please run following cmdlets: $members = Get-DynamicDistributionGroup DDGname Get-Recipient -RecipientPreviewFilter $members.recipientfilter -organizationalunit "abc.abcgrp.net/Business Units" | select displayname,primarysmtpaddressFrank Wang TechNet Community Support
Free Windows Admin Tool Kit Click here and download it now
January 2nd, 2012 10:25pm

Hi Frank, Happy New Year to you. Thanks for the work on this. I have tried the syntax as you suggest, but I get the same error as before. (I didn't think you could have a wildcard at the start of a string?) If you try with 'SMTP:' appended I preusme you do not get the error I do? Cheers Mark.
January 3rd, 2012 3:39am

Update: A colleague has successfully run the command, with my original syntax, successfully. Looks like an issue with my logon or something... strange. However, we still get members with the SMTP domain we wanted to exclude. We're testing further. Cheers
Free Windows Admin Tool Kit Click here and download it now
January 3rd, 2012 4:17am

Hi Mark, Both cmdlets work in my test lab. But if I run your orginal cmdlet('SMTP:' appended ), the result is not expected as I said. If possible, please run the cmdlet on another Exchange 2007 server or install the Management Tool on client to test. How to Install the Exchange 2007 Management Tools http://technet.microsoft.com/en-us/library/bb232090(EXCHG.80).aspxFrank Wang TechNet Community Support
January 3rd, 2012 4:18am

Right, I understand. We now have it running with the desired results. Took a colleague running it to do this, but at least we are working! Many thanks to all.
Free Windows Admin Tool Kit Click here and download it now
January 3rd, 2012 4:44am

Guys, I am trying to use the snippet above to perform something a little similair see below. First try New-DynamicDistributionGroup -Name "Block External Email" -Alias "Block All External Email" -OrganizationalUnit "corp.internal" -RecipientFilter {((RecipientType -eq 'UserMailbox') -and (Email Addresses -like 'smtp:*@otml.internal'))} -RecipientContainer "corp.internal" Another go New-DynamicDistributionGroup -Name "Block External Email" -Alias "Block_All_External_Email1" -RecipientFilter {((RecipientType -eq 'UserMailbox') -and (EmailAddresses -like 'smtp:*@otml.internal'))} Tried using '*@otml.internal'))} as well. The issue i have is that it isn't actually grabbing all of the user's with an @otml.internal address i plan on using this dynamic DL to restrict all user's with this email address from sending outbound email.
July 8th, 2012 4:33am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics