How to delete mailbox from database and release the storage?

5,217

Solution 1

Offline defrags? Is it 2005?

Create a new database and move the mailboxes. Zero risk, zero downtime - unlike an offline defrag.

If you really don't have the space, then another option would be to stand up a temporary Exchange server, move those mailboxes you want to delete to that temporary server and delete them from there. That should give the white space back to the database much quicker than anything else.

Finally, there is another technique to remove those mailboxes using remove-storemailbox. It is outlined in this blog posting:

http://blog.enowsoftware.com/solutions-engine/bid/131820/Moving-Exchange-2010-Mailboxes-to-Create-White-Space

Solution 2

Deleting the mailboxes isn't going to reduce the size of the mailbox database file. You need to perform an offline defrag of the mailbox database to shrink the file. You might be better off moving all mailboxes to a new mailbox database and removing/deleting the original mailbox database, if you have enough disk space to do so.

Solution 3

List out mailboxes and remove

Get-Mailbox  -Database <database> 

You can do something fast like

Get-Mailbox  -Database DB02 >> C:\MailboxesToDelete.txt

and then

$users=Get-Content C:\MailboxesToDelete.txt
foreach ($user in $users) {
    Try{
    #Print to screen user mailbox to delete
    Write-Host "User: $($User)"
    #Mark Mailbox for delete
    Disable-Mailbox -Identity $user
    #Success
    Write-Host Success -foregroundcolor green
    "$($User),Pass" | Add-Content $logfile
    }

You also need to perform offline defrag

https://blogs.technet.microsoft.com/rmilne/2013/08/23/offline-defrag-and-dag-databases-oh-my/

Share:
5,217

Related videos on Youtube

Root Loop
Author by

Root Loop

Updated on September 18, 2022

Comments

  • Root Loop
    Root Loop over 1 year

    I need to delete some user mailboxes from exchange 2013 database to release the storage. Each of those mailbox has 40-50G of data. Those mail boxes have been exported as backups. There is a retention period of 14 days by default that all deleted items will still be hold in database. The situation is that I need space right now and I want to bypass this retention period and have those mailboxes removed from the hard drive imminently.

    Is there a way to do this? I could not find the solution online....

    Note: They are disconnected mailboxes, User accounts will still be in AD.

  • Root Loop
    Root Loop about 8 years
    The problem is the space .......I don't have any extra space on my SAN...all taken by exchange.....OMG....what am i gonna do? No budget to buy any drives....
  • Daniel
    Daniel about 8 years
    The first thing you should do is not panicking :) Then follow Joe's advice. :) If you have a backup if your Exchange, the defraging and compacting the dB should be safe. Have not done it more than 6-7 times, but I never had a problem. Although, start the defrag after work.
  • JFL
    JFL about 8 years
    A defrag will NOT free space if the retention period is not over. So you first have to change the retention period to 0 day, wait for the next maintenance (or modify the maintenance schedule) and check the log to ensure the mailboxes have been marked deleted, then you can perform the defrag.
  • TomTom
    TomTom about 8 years
    Sadly also not usable given that there seems to be no space available at all. The OP has nicely put himself into a corner - no magic bullets.
  • Sembee
    Sembee about 8 years
    An offline defrag isn't going to be possible either. If there is space to do an offline defrag then there is space to build a temporary server.
  • Root Loop
    Root Loop about 8 years
    This looks like a doable solution. Fight for budget first.