Comparison Operator -match fails using EMS
Hi, I have recently been tasked with updating our current dynamic distribution groups from LDAP to OPATH. One such group has a widely distributed membership and whilst I haven't finished it yet it is failing with the error "Invoke-Command : Cannot bind parameter 'RecipientFilter' to the target. Exception setting "RecipientFilter": "The length of the property is too long. The maximum length is 2048 and the length of the value provided is 2256." My question as a newcomer to Powershell is whether there is a way of condensing what I have already done in order to come within the 2K limit or is there another workaround. --------------------------------------------------------------------------------------------------------------------------------------------- New-DynamicDistributionGroup -Name OpathTest -OrganizationalUnit 'hospital.uk/Users_exchange/distribution groups' -RecipientFilter { ((RecipientType -eq 'UserMailbox') -and (department -like 'accident and emergency*') -or (department -like 'admissions*') -or (department -like 'library*') -or (department -like 'anaesthetics*') -or (department -like 'booking centre*') -or (department -like 'cataract*') -or (department -like 'chief executive office') -or (department -like 'clinical coding*') -or (department -like 'clinical governance*') -or (department -like 'clinical trials*') -or (department -like 'complaints') -or (department -like 'corneal and external diseases') -or (department -like 'corporate governance') -or (department -like 'cvi*') -or (department -like 'electrophysiology') -or (department -like 'eye bank*') -or (department -like 'glaucoma*') -or (department -like 'health records*') -or (department -like 'infection control*') -or (department -like 'childrens ward*') -or (department -like 'medical illustration') -or (department -like 'medical retina') -or (department -like 'nursing*') -or (department -like 'occupational health') -or (department -like 'ocular prosthetics') -or (department -like 'ocular prosthetics') -or (department -like 'oncology') -or (department -like 'optometry') -or (department -like 'orthoptics*') -or (department -like 'paediatrics*') -or (department -like 'pre operative assessment clinic') -or (department -like 'primary care clinic') -or (department -like 'private patients*') -or (department -like 'radiology') -or (department -like 'reading centre*') -or (department -like 'refractive surgery*') -or (department -like 'research*') -or (department -like 'risk*') -or (department -like 'facilities*') -or (department -like 'theatres*') -or (department -like 'accounts*') -or (department -like 'ultrasound') -or (department -like 'purchasingl*') -or (department -like 'external diseases*')) } A workaround the 2k limit was to use the -match operator in order to accept regular expressions and the following was suggested in my posting to: http://www.powershellcommunity.org/Forums/tabid/54/aff/3/aft/6224/afv/topic/afpgj/1/Default.aspx#13272 New-DynamicDistributionGroup -Name OpathTest -OrganizationalUnit 'hospital.uk/Users_exchange/distribution groups' -RecipientFilter { ((RecipientType -eq 'UserMailbox') -and (department -match 'accident and emergency*|admissions*|library*|anaesthetics*|centre*')} Unfortunately the crunch is that this errors: Invoke-Command : Cannot bind parameter 'RecipientFilter' to the target. Exception setting "RecipientFilter": ""-match" is not a valid operator. Reference to the following confirms -match to be a valid operator so I am at a loss why this problem is occuring. http://technet.microsoft.com/en-us/library/bb125229.aspx Any advice appreciated Agedmcse
February 16th, 2011 9:21am

Is it exchange 2010 environment? The symptom can appear when the OU where the users live haven’t been specified in the cmdlet. By default, the DDL only searches in the OU where the DDL lives, not the entire forest, you need to specify the OU where the users live when creating the query. Please try to follow the sample below New-DynamicDistributionGroup -Name "Pacific Northwest" -Alias "Pacific_Northwest" -OrganizationalUnit "contoso.com/Users" -RecipientFilter {((RecipientType -eq 'UserMailbox') -and ((StateOrProvince -eq 'Washington' -or StateOrProvince -eq 'Oregon')))} -RecipientContainer "contoso.com" James Luo TechNet Subscriber Support in forum If you have any feedback on our support, please contact tngfb@microsoft.com 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.
Free Windows Admin Tool Kit Click here and download it now
February 16th, 2011 9:11pm

Hi James, Yes, it is an Exchange 2010 environment. I have tried appending both of my previous attempts with -recipient container '<FQDN/OU> but unfortunately they have failed with the same error messages 1./ Using -like operator : "Invoke-Command : Cannot bind parameter 'RecipientFilter' to the target. Exception setting "RecipientFilter": "The length of the property is too long. The maximum length is 2048 and the length of the value provided is 2256." 2./ Using -match operator : "Invoke-Command : Cannot bind parameter 'RecipientFilter' to the target. Exception setting "RecipientFilter": ""-match" is not a valid operator."Agedmcse
February 17th, 2011 6:24am

Hello, I'm curious if you ever got this resolved. I'm looking at your post with the command you ran and wanted to point out a very important piece which you will see in James' post. Your command includes a set of parenthesis with every "or"... This was known at one point to cause this exact issue. Have you tried it with the exact format provided by James? Like this: {((RecipientType -eq 'UserMailbox') -and ((StateOrProvince -eq 'Washington' -or StateOrProvince -eq 'Oregon')))} And not like this: {((RecipientType -eq 'UserMailbox') -and ((StateOrProvince -eq 'Washington') -or (StateOrProvince -eq 'Oregon')))} Thanks! Kevin Ca - MSFTKevin Ca - MSFT
Free Windows Admin Tool Kit Click here and download it now
March 29th, 2011 3:48am

Hi Kevin, Thanks for your response. No, not resolved yet. I will take another look when I return to office and revert to you with outcome. AlanAgedmcse
March 29th, 2011 11:04am

Hi Kevin, Sorry for the delay in responding, just got out of hospital. Sadly removing the parenthesis either side of the -or operator did not help as the whole string still breaks the 2k limit Invoke-Command : Cannot bind parameter 'RecipientFilter' to the target. Exception setting "RecipientFilter": "The lengt h of the property is too long. The maximum length is 2048 and the length of the value provided is 2256." Kind Regards AlanAgedmcse
Free Windows Admin Tool Kit Click here and download it now
April 28th, 2011 6:06am

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

Other recent topics Other recent topics