Saturday, July 22, 2017

Exchange Find AD Users With TargetAddress Set

I recently wrapped up a Lotus Notes to Exchange migration and during co-existence we needed to have the TargetAddress attribute set on Exchange mailboxes so mail would forward back to Notes until their mailboxes were moved over.
The issue I had was after migrating the last of the Shared Mailboxes, some users complained that the mailboxes weren't receiving mail.
What happened was after we migrated, we overlooked a few of those that still had TargetAddress attributes set. So I needed to find all mailboxes that still had them.
But the catch is, we have two Resource Forests that are synced with MIM, so I have MailUsers from another domain that do have TargetAddresses, and I don't want to touch those.
With PowerShell, it's real quick to find those Users that match my specific domain.
First, what is a TargetAddress?
The TargetAddress attribute is an Active Directory User property that forwards mail to a mailbox located somewhere other than your Exchange. This can be external, another Exchange environment, or in my case a Notes system.
To find all users that have the TargetAddress set, for a specific domain and export to a TXT file, run the following cmdlet in the Exchange Management Shell or the Active Directory PowerShell:
Get-aduser -filter {targetAddress -like "*.domain.com"} -properties * | Select-Object Name, targetaddress | Out-File C:\Temp\TargetAddresses.txt
**Note** Change "*.domain.com" to your domain name and change the out-file path.

Now you can go remove those in bulk by following my previous post here.

No comments:

Post a Comment