Forum Discussion
Thorsten80
Apr 14, 2022Copper Contributor
ExchangeOnline Transport Regeln
Hallo, ich versuche gerade per Powershell eine neue Transportregel anzulegen. Es geht um ExceptIfSubjectOrBodyMatchesPatterns, es soll also geprüft werden, ob im Betreff oder im Mailtext ein ...
- Apr 14, 2022Solution:
There ist no problem with regex. I used the wrong statement.
Correct Statement: -SubjectOrBodyMatchesPatterns
VG
Thorsten80
Apr 14, 2022Copper Contributor
Hello,
I'm trying to create a new transport rule using powershell.
It's about ExceptIfSubjectOrBodyMatchesPatterns, so it should be checked whether a certain pattern is found in the subject or in the mail body.
Specifically, the e-mail should be checked to see whether it contains a specific link and the e-mail should then not be sent.
I'm now able to create new rules using Powershell, display them and delete them again, but the correct form of the pattern for recognizing the link doesn't work.
Maybe someone has an idea how the pattern should look like.
Link that must not be included: https://meinedomäne.de/erp/....
Especially the part /erp/ is always the same.
My approach so far has been:
$pattern1 = "((\/)(e|E)(r|R)(p|P)(\/))"
New-TransportRule -name "Block-Mail-with-Link" -ExceptIfSubjectOrBodyMatchesPatterns $pattern1 -Priority '0' -Enabled $true -GenerateIncidentReport "Email address removed"
I only have a report generated there so as not to disturb the mail dispatch during testing.
I achieve the actual blocking with
New-TransportRule "Links with Pattern" -ExceptIfSubjectOrBodyMatchesPatterns *Pattern* -RejectMessageReasonText "Links with ERP were detected in the subject or mail body" -Enabled $True
VG
I'm trying to create a new transport rule using powershell.
It's about ExceptIfSubjectOrBodyMatchesPatterns, so it should be checked whether a certain pattern is found in the subject or in the mail body.
Specifically, the e-mail should be checked to see whether it contains a specific link and the e-mail should then not be sent.
I'm now able to create new rules using Powershell, display them and delete them again, but the correct form of the pattern for recognizing the link doesn't work.
Maybe someone has an idea how the pattern should look like.
Link that must not be included: https://meinedomäne.de/erp/....
Especially the part /erp/ is always the same.
My approach so far has been:
$pattern1 = "((\/)(e|E)(r|R)(p|P)(\/))"
New-TransportRule -name "Block-Mail-with-Link" -ExceptIfSubjectOrBodyMatchesPatterns $pattern1 -Priority '0' -Enabled $true -GenerateIncidentReport "Email address removed"
I only have a report generated there so as not to disturb the mail dispatch during testing.
I achieve the actual blocking with
New-TransportRule "Links with Pattern" -ExceptIfSubjectOrBodyMatchesPatterns *Pattern* -RejectMessageReasonText "Links with ERP were detected in the subject or mail body" -Enabled $True
VG
Thorsten80
Apr 14, 2022Copper Contributor
Solution:
There ist no problem with regex. I used the wrong statement.
Correct Statement: -SubjectOrBodyMatchesPatterns
VG
There ist no problem with regex. I used the wrong statement.
Correct Statement: -SubjectOrBodyMatchesPatterns
VG