Export Exchange recipients to Postfix server

When  you have an Exchange server in your organization and you also use a Postfix server as gateway, you need the list of all valid recipients of your organization at your gateway. In this way, you can reject invalid emails at the gateway, and what’s more important, when the sender address is forged, you don’t spam innocent people with undeliverable emails.

I use this script in Exchange 2003 to generate all addresses.

[Read More]

Eliminar buzones de usuarios deshabilitados en Exchange 2010

Aquí os pongo un script que borra los buzones de Exchange de los usuarios deshabilitados en AD. Comprueba que sean del tipo UserMailbox, porque hay buzones como los RoomMailbox cuyo usuario está deshabilitado, cuidado con esto.

Es necesario tener instalado los comandos powershell para Active Directory de Quest.

# Script que deshabilita los buzones de todos los usuarios de AD deshabilitados

Add-PSSnapin Quest.ActiveRoles.ADManagement -ErrorAction SilentlyContinue | Out-Null
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction SilentlyContinue | Out-Null

$DisabledMailboxes = New-Object -TypeName Microsoft.Exchange.Data.Directory.Management.Mailbox
$DisabledMailboxes = $null
Get-QADUser -Disabled -SizeLimit 0 | foreach-object {
   $ID = $_.samaccountname
   $mbx = Get-Mailbox -Identity $ID -RecipientTypeDetails UserMailbox  -ErrorAction SilentlyContinue
   If ($mbx) {
      Write-Host "Añado a la lista: " $mbx.Name
      $DisabledMailboxes += $mbx
   }
}
If ($DisabledMailboxes) {
   $DisabledMailboxes | foreach-object {
      Write-Host "Deshabilito el buzón: " $_.Name
      $_ | Disable-Mailbox -Confirm:$false
   }
}
Get-MailboxDatabase | Clean-MailboxDatabase