Skip to content

Instantly share code, notes, and snippets.

@supermarsx
Last active March 25, 2025 13:42
Show Gist options
  • Save supermarsx/4c6cf0c48af3558e8ac2d47c3729499c to your computer and use it in GitHub Desktop.
Save supermarsx/4c6cf0c48af3558e8ac2d47c3729499c to your computer and use it in GitHub Desktop.
Exchange filter, Block Suspicious TLDs
$blacklist = @(
"@*\.accountant$",
"@*\.accountants$",
"@*\.adult$",
"@*\.am$",
"@*\.asia$",
"@*\.autos$",
"@*\.bar$",
"@*\.bd$",
"@*\.best$",
"@*\.bet$",
"@*\.bid$",
"@*\.bio$",
"@*\.blue$",
"@*\.buzz$",
"@*\.cam$",
"@*\.casa$",
"@*\.casino$",
"@*\.cc$",
"@*\.cd$",
"@*\.cf$",
"@*\.cfd$",
"@*\.charity$",
"@*\.click$",
"@*\.club$",
"@*\.cm$",
"@*\.cn$",
"@*\.com.na$",
"@*\.country$",
"@*\.cricket$",
"@*\.cyou$",
"@*\.dad$",
"@*\.date$",
"@*\.degree$",
"@*\.download$",
"@*\.earth$",
"@*\.email$",
"@*\.faith$",
"@*\.fit$",
"@*\.fund$",
"@*\.futbol$",
"@*\.fyi$",
"@*\.ga$",
"@*\.gdn$",
"@*\.ge$",
"@*\.gives$",
"@*\.gold$",
"@*\.gq$",
"@*\.guru$",
"@*\.haus$",
"@*\.help$",
"@*\.homes$",
"@*\.host$",
"@*\.icu$",
"@*\.id$",
"@*\.il$",
"@*\.in$",
"@*\.info$",
"@*\.ink$",
"@*\.jetzt$",
"@*\.ke$",
"@*\.kim$",
"@*\.lat$",
"@*\.lease$",
"@*\.life$",
"@*\.link$",
"@*\.live$",
"@*\.lk$",
"@*\.loan$",
"@*\.lol$",
"@*\.ltd$",
"@*\.makeup$",
"@*\.me$",
"@*\.men$",
"@*\.ml$",
"@*\.mom$",
"@*\.monster$",
"@*\.mov$",
"@*\.ng$",
"@*\.ninja$",
"@*\.online$",
"@*\.party$",
"@*\.pics$",
"@*\.pk$",
"@*\.plus$",
"@*\.poker$",
"@*\.porn$",
"@*\.pro$",
"@*\.pub$",
"@*\.pw$",
"@*\.py$",
"@*\.quest$",
"@*\.racing$",
"@*\.realtor$",
"@*\.ren$",
"@*\.rest$",
"@*\.review$",
"@*\.rip$",
"@*\.rocks$",
"@*\.rodeo$",
"@*\.ru$",
"@*\.run$",
"@*\.sa$",
"@*\.sbs$",
"@*\.science$",
"@*\.sex$",
"@*\.sexy$",
"@*\.shop$",
"@*\.site$",
"@*\.skin$",
"@*\.space$",
"@*\.stream$",
"@*\.su$",
"@*\.support$",
"@*\.th$",
"@*\.tk$",
"@*\.tn$",
"@*\.today$",
"@*\.tokyo$",
"@*\.top$",
"@*\.trade$",
"@*\.tube$",
"@*\.uno$",
"@*\.vip$",
"@*\.wang$",
"@*\.webcam$",
"@*\.wiki$",
"@*\.win$",
"@*\.work$",
"@*\.world$",
"@*\.ws$",
"@*\.wtf$",
"@*\.xin$",
"@*\.xn--2scrj9c$",
"@*\.xn--5tzm5g$",
"@*\.xn--6frz82g$",
"@*\.xn--czrs0t$",
"@*\.xn--fjq720a$",
"@*\.xn--s9brj9c$",
"@*\.xn--unup4y$",
"@*\.xn--vhquv$",
"@*\.xn--xhq521b$",
"@*\.xxx$",
"@*\.xyz$",
"@*\.za.com$",
"@*\.zip$",
"@*\.zone$",
"@*\.zw$"
)
# Name of the transport rule
$ruleName = "Block Suspicious TLDs"
# Check if the rule already exists
$existingRule = Get-TransportRule -Identity $ruleName -ErrorAction SilentlyContinue
if ($existingRule) {
Set-TransportRule -Identity $ruleName -FromAddressMatchesPatterns $blacklist -DeleteMessage $true
} else {
New-TransportRule -Name $ruleName -FromAddressMatchesPatterns $blacklist -DeleteMessage $true
}
Write-Output "Sender address pattern blacklist updated successfully."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment