-
-
Save vexx32/c162230e5352816fac90df23cc7b6bd6 to your computer and use it in GitHub Desktop.
This file contains 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-ABMEmails { | |
[CmdletBinding()] | |
param( | |
[Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] | |
[string[]] | |
$MessageId | |
) | |
begin{} | |
process{ | |
foreach ($Id in $MessageId) { | |
Get-MessageTrace -MessageId $Id | | |
Select-Object -Property RecipientAddress, SenderAddress, Subject | |
} | |
} | |
end{} | |
} | |
function Remove-ABMEmails { | |
[CmdletBinding()] | |
param( | |
[Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] | |
[string[]] | |
$MessageId | |
) | |
process { | |
foreach ($Id in $MessageId) { | |
$Trace = SearchABMEmails -MessageID $Id | |
foreach ($Identity in $Trace) { | |
Search-Mailbox -Identity $RecipientAddress -SearchQuery "Subject:$Subject AND From:$SenderAddress" -DeleteContent | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment