New-TransportRule AD Attributes RRS feed

  • Question

  • Hi,

    I would like to create an Exchange 365 transport rule (for a signature) with the condition of any text in the MobileNumber field. I'm expecting it to be something like 

    New-TransportRule "Mobile User" -SenderADAttributeMatchesPatterns "MobileNumber: \w"

    Or perhaps -SenderADAttributeContainsWords, or -ExceptIf... null something. There appears to be a GUI option for this but it doesn't seem to work correctly. Basically, I can't work out what to use for the pattern or words to match.

    I'm pretty new to PowerShell, if you can see an obvious solution I'm missing please let me know.

    Tuesday, March 19, 2019 4:35 PM

All replies

  • What regex you use will depend on what the contents of that property might be. In other words, what pattern are you trying to match?

    \w is a shorthand for the character class  "[A-Za-z0-9_]". If your sender's mobile number contains, for instance, a "+", "-","(", or ")" then the "\w" won't match.

    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)

    • Proposed as answer by jrv Wednesday, March 20, 2019 12:23 AM
    Tuesday, March 19, 2019 6:31 PM
  • "Patterns" and "Words" are plural.  They can both take an array of patterns or words.

    Start here: https://docs.microsoft.com/en-us/powershell/module/exchange/policy-and-compliance/new-transportrule?view=exchange-ps

    Study all of the details and the examples.


    Wednesday, March 20, 2019 12:23 AM