Retaining Mailbox for Disabled User Accounts

20 Sep

Some Organizations requires retaining emails for employees who left on the production Exchange mailbox database .to get the benefits of exchange HA and Exchange Audit.

So they can disable user account and keep mailbox in the mailbox database.

However, even if you disable user account associated with that mailbox, you need to address the following:

1- Email address will be still viewable in GAL and address book and

2- Mailbox will continue receiving emails.

I have written this script will do the following:

  • First, This script assuming user accounts are already disabled .by any AD tool.
  • Then, It will verify all exchange attributes for the user account will are updated.(Set-Mailbox -ApplyMandatoryProperties)
  • It will exclude all discovery mailboxes and Shared mailboxes
  • for each mailbox , it will:
    • hide email from GAL , Address book.
    • restrict mailbox receiving emails accept only from dummy user
Get-Mailbox -resultsize unlimited |Set-Mailbox -ApplyMandatoryProperties
$DisabledUsers=Get-Mailbox -resultsize unlimited |?{$_.ExchangeUserAccountControl -Match "AccountDisabled" -and $ -notlike "DiscoverySearchMailbox*" -and $_.RecipientTypeDetails -ne "SharedMailbox"} 
foreach ($DisabledUser in $DisabledUsers){
Set-Mailbox $DisabledUser -HiddenFromAddressListsEnabled $true -AcceptMessagesOnlyFrom }

you can store this script in ps1 file and schedule running it as a scheduled task the link below can help you.

How to schedule Exchange Server Scripts using PowerShell


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: