【发布时间】:2022-12-30 01:00:56
【问题描述】:
我正在寻找一个脚本来查询整个组织(所有邮箱),找到设置为转发、重定向或作为附件转发到外部地址的收件箱规则,并输出到具有用户 ID、规则名称和外部的文件收件人 smtp。
到目前为止,我已经写过类似的东西。
特别是,我得到了非常奇怪的 Ruledescription 和 RedirectTo 输出。我们如何解决这个问题?
脚本 :
Get-Mailbox -ResultSize Unlimited |
foreach {
Write-Verbose "Checking $($_.alias)..." -Verbose
$inboxrule = get-inboxrule -Mailbox $_.alias
if ($inboxrule) {
foreach($rule in $inboxrule){
[PSCustomObject]@{
Mailbox = $_.alias
Rulename = $rule.name
Rulepriority = $rule.priority
Ruledescription = $rule.description
ForwardTo = $rule.ForwardTo
ForwardAsAttachmentTo = $rule.ForwardAsAttachmentTo
RedirectTo = $rule.RedirectTo
DeleteMessage = $rule.DeleteMessage
}
}
}
} |
Export-csv "C:\temp\inbox_ruleexport.csv" -NoTypeInformation -encoding UTF8
输出 :
"Mailbox","Rulename","Rulepriority","Ruledescription","ForwardTo","ForwardAsAttachmentTo","RedirectTo","DeleteMessage"
"user","[all forwarding]","1","Take the following actions:
redirect the message to 'user@contoso.com'
and stop processing more rules on this message
",,,"Microsoft.Exchange.Data.Storage.Management.ADRecipientOrAddress[]","False"
【问题讨论】:
标签: powershell