none
Effect of PowerShell to Remove Exchange Attributes RRS feed

  • Question

  • If you use a PowerShell Script like the one below, shouldn't the mailbox show up in the Exchange 2010 console under disconnected mailboxes?

    Remove Exchange Attributes
    ----------------------------

    Remove Exchange 2010 Attributes for a Corrupted Active Directory Account

    Caution : Mailbox Will Go Disconnected and Exchange Attributes will be Removed" -ForeGround "Cyan"


    $EnterUser = Read-Host "Enter Alias"

    $ADaccount = Get-User "$EnterUser"

    $FullDistinguishName = "LDAP://" + $ADaccount.distinguishedName

    $AccountEntry = New-Object DirectoryServices.DirectoryEntry $FullDistinguishName

    $AccountEntry.PutEx(1, "mail", $null)
    $AccountEntry.PutEx(1, "HomeMDB", $null)
    $AccountEntry.PutEx(1, "HomeMTA", $null)
    $AccountEntry.PutEx(1, "legacyExchangeDN", $null)
    $AccountEntry.PutEx(1, "msExchMailboxAuditEnable", $null)
    $AccountEntry.PutEx(1, "msExchAddressBookFlags", $null)
    $AccountEntry.PutEx(1, "msExchArchiveQuota", $null)
    $AccountEntry.PutEx(1, "msExchArchiveWarnQuota", $null)
    $AccountEntry.PutEx(1, "msExchBypassAudit", $null)
    $AccountEntry.PutEx(1, "msExchDumpsterQuota", $null)
    $AccountEntry.PutEx(1, "msExchDumpsterWarningQuota", $null)
    $AccountEntry.PutEx(1, "msExchHomeServerName", $null)
    $AccountEntry.PutEx(1, "msExchMailboxAuditEnable", $null)
    $AccountEntry.PutEx(1, "msExchMailboxAuditLogAgeLimit", $null)
    $AccountEntry.PutEx(1, "msExchMailboxGuid", $null)
    $AccountEntry.PutEx(1, "msExchMDBRulesQuota", $null)
    $AccountEntry.PutEx(1, "msExchModerationFlags", $null)
    $AccountEntry.PutEx(1, "msExchPoliciesIncluded", $null)
    $AccountEntry.PutEx(1, "msExchProvisioningFlags", $null)
    $AccountEntry.PutEx(1, "msExchRBACPolicyLink", $null)
    $AccountEntry.PutEx(1, "msExchRecipientDisplayType", $null)
    $AccountEntry.PutEx(1, "msExchRecipientTypeDetails", $null)
    $AccountEntry.PutEx(1, "msExchTransportRecipientSettingsFlags", $null)
    $AccountEntry.PutEx(1, "msExchUMDtmfMap", $null)
    $AccountEntry.PutEx(1, "msExchUMEnabledFlags2", $null)
    $AccountEntry.PutEx(1, "msExchUserAccountControl", $null)
    $AccountEntry.PutEx(1, "msExchVersion", $null)
    $AccountEntry.PutEx(1, "proxyAddresses", $null)
    $AccountEntry.PutEx(1, "showInAddressBook", $null)
    $AccountEntry.PutEx(1, "mailNickname", $null)

    $AccountEntry.SetInfo()


    John M.

    Thursday, February 6, 2014 8:20 PM

Answers

All replies

  • If a disconnected mailbox does not show up, you need to run the clean-mailboxdatabase command. See this link for more information - http://technet.microsoft.com/en-us/library/bb124076.aspx.

    JAUCG - Please remeber to mark replies as helpful if they were or as answered if I provided a solution.

    • Marked as answer by DenverITGuy Wednesday, July 23, 2014 2:37 PM
    Thursday, February 6, 2014 10:24 PM
  • Can you provide any further information or troubleshooting?

    JAUCG - Please remeber to mark replies as helpful if they were or as answered if I provided a solution.

    Monday, February 10, 2014 9:35 PM
  • Hello! This script works great for me! However, I'm trying to have it read a .csv file with a list of usernames, but removing the $EnterUser = Read-Host "Enter Alias" and $ADaccount = Get-User "$EnterUser", then replacing it with an Import-CSV seems to throw errors. I'm new to Powershell... would you be able to show me the proper code to remove these exchange attributes based on a list of usernames? Your help would be appreciated! Thank you!

    Friday, July 27, 2018 3:42 PM
  • Hello Act1WithMe did you ever get an answer?  Would love to see the results.

    Tuesday, October 30, 2018 5:50 PM
  • in some case like moved mail user, you need to add

    $AccountEntry.PutEx(1, "targetAddress", $null) 

    Friday, September 4, 2020 8:03 AM