Using Powershell to Correct 9325 Events in Exchange 2007

Per knowledge base article 936197, Exchange 2007 may be dropping recipients from the Offline Address book and generating any of the following errors in the event log (note that diagnostic logging on the Exchange server needs to be set to High or Expert to see these events).

 

Event Type: Error

Event Source: MSExchangeSA

Event Category: OAL Generator

Event ID: 9325

Date: 8/23/2007

Time: 9:25:43 AM

User: N/A

Computer: {Exchange Server where OAB is Generated}

Description:

OALGen will skip user entry '{mailBox Name}' in address list '\Global Address List' because the SMTP address '' is invalid.

- [Address Book Name]

The KB article goes into detail about how to fix these problems from a one-off perspective. However, if you find yourself with hundreds of these events, you'll need a PowerShell script to more effectively solve the problem. The script below will take the user's .Mail attribute (WindowsEmailAddress) and sets it as the PrimarySMTPAddress for the user. To work properly, you first need to generate a list of offending users. DUMPEL is probably the easiest way to get this information, pulling the 9325 events into a text file, loading the file into Excel and stripping everything but the user name. The result of this effort produces a text file similar to the following:

 

Rachel Rogers

Dave Smith

John Doe

Alice Anderson

 

Once we have the list, we can feed into the following PowerShell script (yours could be parameterized, but for ease of illustration, mine is hardcoded).

 

$users = get-content ListToCorrect.txt

foreach ( $user in $users ) {

$oUser = get-mailuser $user

$winMail = $oUser.WindowsEmailAddress

  Set-MailUser -identity "$oUser" -EmailAddressPolicyEnabled:$false -PrimarySMTPAddress $winMail -WindowsEmailAddress $winMail

}

 

A simple update to the Offline Address Book (Get-OfflineAddressBook | Update-OfflineAddressBook) should produce a clean event log.