# encoding: ascii
# api: powershell
# title: Clear-XCAttributes
# description: clear exchange 2003 attributes from AD users
# version: 0.1
# type: script
# author: chriskenis
# license: CC0
# x-poshcode-id: 3797
# x-archived: 2012-12-04T08:43:56
# x-published: 2012-11-29T04:48:00
#
#
param(
[Parameter(Position=0,ValueFromPipeline=$True)]
[ValidateNotNullorEmpty()] $User,
[switch]$ClearXCAttributes
)
begin{
$Global:LegacyXCUsers = @()
# attributes to be nulled according to:
# http://blogs.technet.com/b/exchange/archive/2006/10/13/3395089.aspx
$XCattributes=@(
"adminDisplayName","altRecipient","authOrig","autoReplyMessage","deletedItemFlags","delivContLength","deliverAndRedirect","displayNamePrintable",
"dLMemDefault","dLMemRejectPerms","dLMemSubmitPerms","extensionAttribute1","extensionAttribute10","extensionAttribute11","extensionAttribute12",
"extensionAttribute13","extensionAttribute14","extensionAttribute15","extensionAttribute2","extensionAttribute3","extensionAttribute4","extensionAttribute5",
"extensionAttribute6","extensionAttribute7","extensionAttribute8","extensionAttribute9","folderPathname","garbageCollPeriod","homeMDB","homeMTA",
"internetEncoding","legacyExchangeDN","mail","mailNickname","mAPIRecipient","mDBOverHardQuotaLimit","mDBOverQuotaLimit","mDBStorageQuota","mDBUseDefaults",
"msExchADCGlobalNames","msExchControllingZone","msExchExpansionServerName","msExchFBURL","msExchHideFromAddressLists","msExchHomeServerName",
"msExchMailboxGuid","msExchMailboxSecurityDescriptor","msExchPoliciesExcluded","msExchPoliciesIncluded","msExchRecipLimit","msExchResourceGUID",
"protocolSettings","proxyAddresses","publicDelegates","securityProtocol","showInAddressBook","submissionContLength","targetAddress","textEncodedORAddress",
"unauthOrig"
)
}
process{
$Global:LegacyXCUsers += (get-aduser -Identity $User -Properties *)
if ($ClearXCAttributes){
write-verbose "all XC attributes will be cleared for $user"
set-aduser -Identity $User -Clear $XCattributes
}
}
end{
$Global:LegacyXCUsers
}