KB10103 - Exchange: Backup Attributes

This example shows how to backup the Exchange attribute ForwardingAddress to the field ExtensionCustomAttribute1.

It also shows how to verify if the fieled has changed. It can be used before doing mass changes to mailboxes inside an Exchange organization.


Script code:

	
#Do Backup of Attribute...
$Mailboxes = Get-Mailbox -ResultSize unlimited | Where-Object {$_.ForwardingAddress -ne $null}
foreach ($Mailbox in $Mailboxes) {$DN = $Mailbox.DistinguishedName; Write-Host $DN; $Attr1 = $Mailbox.ForwardingAddress.ToString(); Write-Host $Attr1; Set-Mailbox -Identity "$DN" -ExtensionCustomAttribute1 $Attr1 }
#Do Attribute Check!
$MailboxesCheck = Get-Mailbox -ResultSize unlimited | Where-Object {$_.ExtensionCustomAttribute1 -ne $null}
foreach ($Mailbox in $MailboxesCheck) {Write-Host -NoNewline ("Checking Mailbox: "+$Mailbox.Identity+" ... ");if (($Mailbox.ForwardingAddress.ToString()) -ne $Mailbox.ExtensionCustomAttribute1) {Write-Host -ForegroundColor Red ("Mismatch!!!")} else { Write-Host -ForegroundColor Green ("OK")};}
	

>> syntax highlighting powered by highlight.js