Created
January 26, 2022 16:22
-
-
Save s4parke/7128d755db0ad89f01f7ad7f8550dd57 to your computer and use it in GitHub Desktop.
Search for Blocked or Trusted Senders and Domains in Exchange Online
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Search-BlockedSendersAndDomains { | |
<# | |
.DESCRIPTION | |
Search by keyword in a user's blocked senders and domains. | |
Wildcards are automatically added before and after the search string. | |
.PARAMETER Identity | |
Email address of the user. "[email protected]". | |
.PARAMETER Term | |
Keyword search string. "example.com" | |
.INPUTS | |
A pipeline of user identities might work. | |
.OUTPUTS | |
System.String. | |
.EXAMPLE | |
PS> Search-BlockedSendersAndDomains -Identity "[email protected]" -Term "baz" | |
[email protected] | |
.EXAMPLE | |
PS> Search-BlockedSendersAndDomains "[email protected]" "noreply" | |
[email protected] | |
.EXAMPLE | |
PS> $users = @("[email protected]", "[email protected]") | |
PS> $users | Search-BlockedSendersAndDomains -Term "bubliz" | |
[email protected] | |
[email protected] | |
#> | |
param( | |
[Parameter(Mandatory, ValueFromPipeline, Position=0)] | |
[string]$Identity, | |
[Parameter(Mandatory, Position=1)] | |
[string]$Term | |
) | |
Process { | |
Get-MailboxJunkEmailConfiguration -Identity "$Identity" | | |
Select -ExpandProperty BlockedSendersAndDomains | | |
Where-Object {$_ -like "*$Term*"} | | |
Sort-Object | |
} | |
} | |
function Search-TrustedSendersAndDomains { | |
<# | |
.DESCRIPTION | |
Search by keyword in a user's Trusted senders and domains. | |
Wildcards are automatically added before and after the search string. | |
.PARAMETER Identity | |
Email address of the user. "[email protected]". | |
.PARAMETER Term | |
Keyword search string. "example.com" | |
.INPUTS | |
A pipeline of user identities might work. | |
Use the -Term parameter | |
.OUTPUTS | |
System.String. | |
.EXAMPLE | |
PS> Search-TrustedSendersAndDomains -Identity "[email protected]" -Term "baz" | |
[email protected] | |
.EXAMPLE | |
PS> Search-TrustedSendersAndDomains "[email protected]" "noreply" | |
[email protected] | |
.EXAMPLE | |
PS> $users = @("[email protected], "[email protected]") | |
PS> $users | Search-TrustedSendersAndDomains -Term "bubliz" | |
[email protected] | |
[email protected] | |
#> | |
param( | |
[Parameter(Mandatory, ValueFromPipeline, Position=0)] | |
[string]$Identity, | |
[Parameter(Mandatory, Position=1)] | |
[string]$Term | |
) | |
Process { | |
Get-MailboxJunkEmailConfiguration -Identity "$Identity" | | |
Select -ExpandProperty TrustedSendersAndDomains | | |
Where-Object {$_ -like "*$Term*"} | | |
Sort-Object | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment