more or less

An issue came up at my client recently, where our webmaster email account was being flooded with non deliverable email notices. Messages were bouncing back because our SharePoint farm was sending alerts to users and email address that no longer existed.

This was on a WSS 3.0 farm, and we don’t have any third party tools (like Axceler’s ControlPoint) to help manage scenarios like this. So, I decided to tackle the problem with PowerShell.

This script will loop through all of the Web Applications in the farm, site collections, and webs, looking for all of the alerts. Once an alert is found, it checks to see if the user is still in Active Directory. If not, it adds the alert to a list of alerts to delete.

If you only want it to search through one web application, you can modify line 48 to only continue if the name of the web application matches.

Also note, you’ll need to modify the LDAP path, stored in the $LDAP_Domain variable to match your environment.