Skip to content

How to disable automapping Exchange 2010 for all mailbox

With exchange 2010 post SP1, there’s a new feature that cause lots of problem: AUTOMAPPING

With the below script you can disable all automapped mailbox

 

# Get all mailboxes in the forest
$Mailboxes = Get-Mailbox -ResultSize unlimited -IgnoreDefaultScope -OrganizationalUnit Other
$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.alias |where {$_.AccessRights -eq “FullAccess” -and $_.IsInherited -eq $false}
if ($FixAutoMapping)
{
$FixAutoMapping | Remove-MailboxPermission -confirm:$false
$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
}

}