Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to use the following Regex in exchange 2010 transport rules. Edit: Apologies - I wasn't very clear. I'm trying to match the question mark. I have escaped the question mark but still tells me that I have an error.


Using the command:

PS C:\Windows\system32> New-TransportRule -Name "/([0-9A-F]{6})/\?" -SubjectOrBodyMatchesPatterns '/([0-9A-F]{6})/\?' -RejectMessageEnhancedStatusCode "5.7.1" -RejectMessageReasonText "This message has been rejected because of content restrictions"

I get the returned error message:

New-TransportRule : Cannot bind parameter 'SubjectOrBodyMatchesPatterns'. Cannot convert value "/([0-9A-F]{6})/\?" to t
ype "Microsoft.Exchange.MessagingPolicies.Rules.Tasks.Pattern". Error: "The regular expression you entered contains the
 following error: There's a problem with your use of the backslash ( \ ) character. In a regular expression, the backsl
ash character is used for text pattern matching. For example, "\d" matches any digit from 0 to 9. The backslash charact
er can also be used as an escape character for a special character. For example, "\" searches for the text character "\
At line:1 char:74

How do I escape a question mark in my rule?


share|improve this question
Just to be clear, are you trying to match a literal question mark? –  Michael Hampton Sep 6 '12 at 0:07
Yes I am. I'm trying to match the question mark. –  itwb Sep 6 '12 at 0:26

1 Answer 1

According to the this document, the pattern strings table doesn't contain the question mask. So, remove the backslash and try again.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.