Remove Exchange Mailbox After No Use

Written by Allen White on. Posted in Exchange 2007, Exchange 2010, Exchange 2013

If you like to keep your Exchange organization neat and tidy then this power shell script is for you. It allows you to define an amount of days hat a user has not logged in, if the user does not log into the Exchange mailbox in this amount of time then the mailbox is disabled after the set amount of time. First the script then a brief explanation.

***Test this, Its not my fault if it breaks your system!***


Get-MailboxStatistics | where {$_.LastLogonTime -lt (get-date).addDays(-90)} | Disable-Mailbox

First we query Exchange for all Mailboxes statistics for the last time the mailbox was logged into. We specify the amount of days as 90 here however you can change the amount of days to your choice.  We query the 90 days against the last log on time, if they time exceeds 90 days then mailboxes that have not logged in in this time are disabled. They will then be deleted in your standard Exchange mailbox purge settings.

This applies to Exchange 2007, Exchange 201 and Exchange 2013

Allen White
Allen is a Consultant for ITPS in the North East of England and holds the following accreditations. MCSA, MCSE, MCTS, MCITP, CCA, CCSP, VCP 4,5 and HP ASE, AIS - Network Infrastructure.

ITPS provides strategic IT consultancy, implementation, data centre provision and unified communications, as well as support services and workspace and disaster recovery. If you require a consultation then please contact me via the contacts section or direct on 07931222991, add me on linkedin.


Leave a comment


(c) Please be aware, all information is provided freely, any information used is done so at your risk and Techieshelp will not be held responsible for any issue that may occur.
!-- BuySellAds On-Site Shopping Cart -->