Forum Discussion
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 bestimmtes Pattern gefunden wird.
Konkret soll die Mail darauf geprüft werden, ob ein bestimmter Link enthalten ist und der Mailversand soll dann nicht durchgeführt werden.
Ich schaffe es mittlerweile per Powershell neue Regeln anzulegen, diese anzuzeigen und auch wieder zu löschen, aber die richtige Form des Pattern zur Erkennung des Links geht nicht.
Vielleicht hat jemand eine Idee, wie das Pattern aussehen muss.
Link, der nicht enthalten sein darf: https://meinedomäne.de/erp/....
Vor allem der Teil /erp/ ist immer gleich.
Mein Ansatz war bisher:
$pattern1 = "((\/)(e|E)(r|R)(p|P)(\/))"
New-TransportRule -name "Block-Mail-with-Link" -ExceptIfSubjectOrBodyMatchesPatterns $pattern1 -Priority '0' -Enabled $true -GenerateIncidentReport "Email address removed"
Ich lasse mir da nur einen Report generieren, um die Mailversand beim Testen nicht zu stören.
Die tatsächliche Blockierung erreiche ich mit:
New-TransportRule "Links with Pattern" -ExceptIfSubjectOrBodyMatchesPatterns *Pattern* -RejectMessageReasonText "Im Betreff oder Mailtext wurden Links mir ERP entdeckt" -Enabled $True
VG
- Solution:
There ist no problem with regex. I used the wrong statement.
Correct Statement: -SubjectOrBodyMatchesPatterns
VG
3 Replies
- Thorsten80Copper ContributorHello,
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- Thorsten80Copper ContributorSolution:
There ist no problem with regex. I used the wrong statement.
Correct Statement: -SubjectOrBodyMatchesPatterns
VG
- Thorsten80Copper 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