为所有邮箱删除Exchange 2010自动映射的脚本

我有一个从MSExchangeIS获取应用程序事件错误9646的Exchange 2010 SP3服务器:

Mapi会话[ID] [AD用户]超过了最多500个types为“objtFolder”的对象

研究这个问题,发现这个原因是几个用户在其他人的邮箱上拥有大量的完全访问权限。

由于在SP1中的这种变化, 请参阅Technet文章HERE ,他们现在会自动打开他们有权访问的所有用户,而不是仅在需要时添加或打开它们。

理想情况下,我想要一个脚本,我可以运行全局删除所有用户的-Automapping $ truestring:这应该让他们在需要时访问邮箱,但停止自动打开,占用MAPI会话。

我从上面的URL中尝试了Microsoft Technet脚本,但是看起来没有像预期的那样工作:

[PS]$FixAutoMapping = Get-MailboxPermission sharedmailbox|where {$_AccessRights -eq "FullAccess" -and $_IsInherited -eq $false} The operation couldn't be performed because object sharedmailbox couldn't be found on '[Servername]'. + CategoryInfo : InvalidData: (:) [Get-MailboxPermission], ManagementObjectNotFoundException + FullyQualifiedErrorId : B485A4C7,Microsoft.Exchange.Management.RecipientTasks.GetMailboxPermission 

我假设sharedmailbox是一个特定的示例邮箱,它不存在于我的服务器上:我需要一个脚本来search所有的邮箱,然后将Automapping $ true更改为Automapping $ false以获取邮箱上的任何访问权限。

这可能吗?

这非常简单。 您只需要检索邮箱列表并针对每个邮箱运行示例:

 # Get all mailboxes in the forest $Mailboxes = Get-Mailbox -ResultSize unlimited -IgnoreDefaultScope $ConfirmPreference = 'None' # Iterate over each mailbox foreach($Mailbox in $Mailboxes) { try { # Try to run the example fix against the current $Mailbox $FixAutoMapping = Get-MailboxPermission $Mailbox |where {$_.AccessRights -eq "FullAccess" -and $_.IsInherited -eq $false} $FixAutoMapping | Remove-MailboxPermission $FixAutoMapping | ForEach {Add-MailboxPermission -Identity $_.Identity -User $_.User -AccessRights:FullAccess -AutoMapping $false} } catch { # Inform about the error if unsuccessful Write-Host "Encountered error: $($Error[0].Exception) on mailbox $($Mailbox.DisplayName)" -ForegroundColor Red } }