Remove Mailbox for Disabled User Objects

Following script will look for disabled users with mailboxes and will remove mailbox attributes on these objects.

Get-Mailbox | where { $_.ExchangeUserAccountControl -eq "Accountdisabled" -and $_.recipienttypedetails -eq "usermailbox"  } | select name | Export-Csv c:disableduserswithmailboxes.csv
Import-CSV C:disableduserswithmailboxes.csv | ForEach-Object { remove-mailbox -identity $_."Name" -Confirm:$false }

Leave a Reply

Your email address will not be published. Required fields are marked *

+ 89 = 95