Disabling Mailboxes for all Disabled Users in Domain : Please help?!

Good morning all,

We have hundreds of disabled user accounts in active directory, but they all have active email addresses.  I would like to know the commands to:

1) disable the mailboxes of ALL disabled Active Directory User Accounts

2) delete all disabled mailboxes?

3) set exchange to automatically disable the mailbox when the associated user account is disabled

4) set exchange to delete the mailbox when the associated user account is deleted

Is this possible?  I really would like to clean up our exchange server, but i'm not very savy with all the new Powershell Scripting

Any help is GREATLY appreciated!

Thank you!

July 14th, 2015 4:56pm

You can use below cmdlet to find all the disabled user with mailboxes.

get-user -resultsize unlimited | ?{$_.useraccountcontrol -like "*accountdisabled*" -and $_.recipienttype -eq "usermailbox" -and $_.name -notlike "Discovery*"}

Now what you want to do with those, you have to decide, either Disable-Mailbox or Remove-Mailbox

You can find the differences here... http://exchangeserverpro.com/exchange-2010-difference-between-remove-and-disable-mailbox/

You can run in the bulk like this (verify without Disable-mailbox first to get list of users which it is going to run against)

get-user -resultsize unlimited | ?{$_.useraccountcontrol -like "*accountdisabled*" -and $_.recipienttype -eq "usermailbox" -and $_.name -notlike "Discovery*"} | Disable-Mailbox

You need to setup a scheduled script if you want to disconnect the mailbox for disabled users periodically using above cmdlet mainly...

when associate disable account is deleted, Exchange mailbox will be marked as disconnected anyways and won't receive new ema

Free Windows Admin Tool Kit Click here and download it now
July 14th, 2015 6:59pm

Hi,

Please refer to command given by Amit.

I have found these below articles for your reference:

https://technet.microsoft.com/en-us/library/jj863434(v=exchg.150).aspx

https://technet.microsoft.com/en-us/library/bb232039(v=exchg.150).aspx

Regards,

David 


July 15th, 2015 1:36am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics