Get-InboxRule 但只显示 ForwardTo 或 ForwardAsAttachmentTo 不为空的那些
Get-InboxRule but only show the ones where ForwardTo or ForwardAsAttachmentTo aren't empty
我必须检查我们所有用户的收件箱规则。我设法将所有收件箱规则写入文本文件。但我只需要他们转发给其他邮件的那些。
我目前拥有的:
$mails = get-content D:\test.txt
$test = ForEach ($mail in $mails){
$m = Get-InboxRule -Mailbox $mail | measure
$mail
$m.Count
}
$test| Out-File -FilePath "D:\testresult.txt" -Append
在 Test.txt 我有所有的邮件地址:
john.doe@test.com
john.deer@test.com
johnny.dude@test.com
etc etc.
如何添加检查“where Forwardto -ne $null”?
您应该将它添加到您的 Get-InboxRule
命令中,这样
Get-InboxRule -Mailbox $mail | measure
变成
Get-InboxRule -Mailbox $mail | Where-Object {$_.ForwardTo -ne $Null} | measure
我必须检查我们所有用户的收件箱规则。我设法将所有收件箱规则写入文本文件。但我只需要他们转发给其他邮件的那些。
我目前拥有的:
$mails = get-content D:\test.txt
$test = ForEach ($mail in $mails){
$m = Get-InboxRule -Mailbox $mail | measure
$mail
$m.Count
}
$test| Out-File -FilePath "D:\testresult.txt" -Append
在 Test.txt 我有所有的邮件地址:
john.doe@test.com
john.deer@test.com
johnny.dude@test.com
etc etc.
如何添加检查“where Forwardto -ne $null”?
您应该将它添加到您的 Get-InboxRule
命令中,这样
Get-InboxRule -Mailbox $mail | measure
变成
Get-InboxRule -Mailbox $mail | Where-Object {$_.ForwardTo -ne $Null} | measure