Add-PSSnapin microsoft.exchange* $Subject = '警惕“退税”钓鱼邮件' $From = "it@yx.com" $Sent = "05/09/2023" $Search = "Sent:$Sent AND From:$From AND Subject:$Subject" $KQLQuery=[scriptblock]::create($Search) $TargetMailbox = "liu@yx.com" $TargetFolder = "Search" $DelUser = "p@yx.com" #仅查找 Search-Mailbox -Identity $DelUser -SearchQuery $KQLQuery -LogOnly -TargetMailbox $TargetMailbox -TargetFolder $TargetFolder #删除 Search-Mailbox -Identity $DelUser -SearchQuery $KQLQuery -DeleteContent -Force #查找全员邮箱并进行删除 Get-Mailbox |Search-Mailbox -SearchQuery $KQLQuery -DeleteContent -Force
标签:Search,批量,Exchange,KQLQuery,Mailbox,DelUser,Sent,邮件,TargetFolder From: https://www.cnblogs.com/dreamer-fish/p/17388631.html