Last active
February 27, 2024 01:04
-
-
Save azure365pro/9fa782c22b44f8421393b71d87fbdea5 to your computer and use it in GitHub Desktop.
Remove Exchange Attributes using PowerShell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Requires -version 2 | |
<# | |
.SYNOPSIS | |
RemoveExchangeAttributes.ps1 - It Will Remove Exchange Attributes from Active Directory Accounts | |
Caution : Mailbox Will Go Disconnected and Exchange Attributes will be Removed" | |
.DESCRIPTION | |
Remove Exchange 2010 Attributes for a Corrupted Active Directory Account | |
After an Exchange Server Crash. At times Some Active Directory accounts will get corrupted | |
and It will not allow to disable the mailbox | |
Its hard to Have all the Exchange attributes to get to Null . | |
So simplied the task into a simple script. Where we can set the Exchange attributes to Null in one shot | |
.EXAMPLE | |
[PS] C:\>.\RemoveExchangeattributes.ps1 | |
Remove Exchange Attributes | |
---------------------------- | |
Remove Exchange 2010 Attributes for a Corrupted Active Directory Account | |
Caution : Mailbox Will Go Disconnected and Exchange Attributes will be Removed | |
Enter Alias: Manager | |
.NOTES | |
Written By: Satheshwaran Manoharan | |
Website : Www.careexchange.in | |
Change Log | |
V1.0, 08/11/2012 - Initial version | |
#> | |
#Add Exchange 2010 snapin if not already loaded | |
if (!(Get-PSSnapin | where {$_.Name -eq "Microsoft.Exchange.Management.PowerShell.E2010"})) | |
{ | |
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction SilentlyContinue | |
} | |
Write-host " | |
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment