Exchange Remove Disabled Delegates

      No Comments on Exchange Remove Disabled Delegates

Removing Disabled Exchange Delegates with PowerShell

The PowerShell script in this article will retrieve all mailboxes in an Exchange environment and remove Full Access, Send-As, and Send-On-Behalf permissions from them. The final report is adequate for reporting mailbox delegates as well.

Anyone in an organization using Microsoft Exchange knows there are many reasons to grant individual access to another mailbox. So what happens when a user leaves an organization? If your IT Department deletes the user’s Active Directory account, this might not apply to you. However, depending on the IT department, it’s possible that accounts are disabled and then kept in Active Directory.

Scenario:
As employees leave your organization, their Active Directory accounts are disabled. Without manually removing delegates from Exchange mailboxes, the number of disabled delegates assigned to mailboxes increases until going back to “clean them up” is unmanageable; leaving these accounts in place could leave a potential security risk.

Solution:
Automating Exchange delegate cleanup steps with PowerShell.
Deleting delegates from shared mailboxes with PowerShell is done by looping through all Exchange mailboxes and reading the delegates on them. The script then does a one-time lookup in Active Directory for users and saves their status (Enabled/Disabled) for future reference; this saves from doing many queries against AD.

When running the script you will only need to provide your domain’s name, as it appears in Active Directory (samAccountName), but just a heads up: This script can take hours to complete.

If you do not wish to copy this script, click this to save the .ps1: Download

When this script runs, you’ll get decent console output and the delegate report will include all of those delegates found, as well as those that have been removed:

Exchange Delegate Removed

Shell output

Delegate cleanup report

Delegate cleanup report

 

Leave a Reply

Your email address will not be published.