Remove Disabled mailbox


Quick one – a little PowerShell to remove a user who you have Disabled.

Get-MailboxStatistics –Database DATABSE| where {$_.DisplayName -eq "Users Name"} | foreach {Remove-StoreMailbox -Database $_.Database -Identity $_.mailboxguid -MailboxState Disabled}

 

Note, this could be changed to the following;

Get-MailboxStatistics –Database DATABSE| where {$_.DisconnectedReason -eq "Disabled"} | foreach {Remove-StoreMailbox -Database $_.Database -Identity $_.mailboxguid -MailboxState Disabled}

 

Which *should* remove all Disabled mailboxes in the DATABASE specified (I haven’t tested this, only the single user one (I also only tested in 2010 – but the same premise should stick for 2007 too))

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: