Dav*_*ave 5 powershell exchange exchange-2010 outlook-2007 outlook-2010
我有一台 Exchange 2010 SP3 服务器,它从 MSExchangeIS 获取应用程序事件错误 9646:
Mapi 会话 [ID] [AD 用户] 超过了“objtFolder”类型的最大 500 个对象
对此进行调查,发现原因是几个用户对其他人的邮箱拥有大量完全访问权限。
由于这种方式在 SP1 中发生了变化,请参阅此处的 Technet 文章,他们现在会自动打开他们有权访问的所有用户,而不是仅在需要时才能够添加或打开它们。
理想情况下,我想要一个脚本,我可以运行它来全局删除所有用户的 -Automapping $true 字符串:这应该让他们在需要时访问邮箱,但阻止它自动打开,占用 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
Run Code Online (Sandbox Code Playgroud)
我假设 sharedmailbox 是一个在我的服务器上不存在的特定示例邮箱:我需要一个脚本来搜索所有邮箱,然后将 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
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6931 次 |
| 最近记录: |