Stuck in the Past! SharePoint Alerts Pointing to An Old URL After Migration?

I've run into this personally a couple of times and never really documented my own solution so that I had it for myself to reuse. If the URL for your SharePoint Farm ever changes, you're more than likely to start hearing from your users that the alert subscription emails they get still point to the old Farm URL. I've encountered this on SP 2007 and SP 2010 Farms.

As it turns out, each Alert Subscription contains a hard-coded server root URL which is used when the alert email is generated to construct links. I wrote the PowerShell script below to loop through all Web Applications of the server and perform an update on all Alert Subscriptions. I like my scripts that need to be run on all sites to run through my whole farm rather than one site at a time. This script works on both SP 2007 and SP 2010. It will skip the Central Admin Web Application, your SSP, and MySite sites.

$oldrooturl = "https://<url>"

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Portal") > $null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Security") > $null

$farm = [Microsoft.SharePoint.Administration.SPFarm]::Local;
$services = @($farm.Services | where -FilterScript {$_.GetType() -eq [Microsoft.SharePoint.Administration.SPWebService]})

foreach ($service in $services) {
    foreach($app in $service.WebApplications) {
        if ($app.DisplayName.Contains('Central Administration')) {
            continue
        }
        $sites = $app.Sites
        foreach ($site in $sites) {
            if (!$site.ServerRelativeUrl.Contains("ssp/") -and !$site.ServerRelativeUrl.Contains("MySite")) {
                $rooturl = $site.Url.Replace($site.ServerRelativeUrl, '')
                foreach ($web in $site.AllWebs) {
                    $updated = 0
                    $alerts = $web.alerts
                    Write-Host "Number of Alerts in: $($web.url) : $($alerts.count)"
                    if ($alerts.count -ne 0) {
                        foreach ($alert in $alerts) {
                            $alert.Status = [Microsoft.SharePoint.SPAlertStatus]::Off
                            $alert.Update()
                            if ($alert.Properties -ne $null) {
                                $siteUrl = $alert.Properties["siteurl"]
                                if ($siteUrl -ne $null -and $siteUrl.Contains($oldrooturl)) {
                                    # Logic for URL replacement would go here
                                }
                            }
                        }
                    }
                    $web.Dispose()
                }
            }
            $site.Dispose()
        }
    }
}

Update: This PowerShell script is now maintained in my blog-code repository on GitHub. You can find the full script and documentation in the /PowerShell-SP-Alert-Fix directory.

Author’s Note: This article reflects my personal professional experience and opinions. While my insights are informed by my professional history, these views are my own and do not represent the official position of my former employer.

About the Author: Jacob Marks is an engineering leader with over 20 years of experience, including a decade at Amazon Web Services (AWS) where he led teams in EC2 Core Platform and the development of the AWS Payment Cryptography service.

Labels

.NET .NET 10 .NET 3.5 Active Directory AD DS Adoption AI AI coding AI Ethics AI Hype Alerts Amazon Cognito Amazon DLM Amazon Q Anthropic AppDomain Architecture Artificial Intelligence Asia Pacific Sydney ASP.net ASPxGridView Audit Readiness Auto Recovery Automation AWS AWS Certified AWS Lambda AWS Payment Cryptography AWS SDK AWS Security Specialty Azure Azure DevOps Server Backup BIG-IP C# Career Growth Cartes Bancaires CB Certificate Bundle Certification Claude Cloud Cloud Certification Cloud Hosting Cloud Security CloudWatch CLR Content Query Cost Optimization Credentials CyberChef Database Defense Industry Deloitte Developer Tools Developers DevEx DevExpress DevOps DISA Disk Space DISM Distributed Systems DoD DoD CC SRG DUKPT EBS EC2 Engineering Engineering Leadership Engineering Management EnPasFltV2 Enterprise Event Receiver Exam F5 Federal IT FedRAMP Fintech FISMA GAC Generative AI GitHub gMSA GovCloud Government Compliance GridView Hardware Security Modules HSM IAM Identity Management IIS Infra Infrastructure as Code IT Tools Jacob Marks JavaScript jQuery Lambda Leadership Linqpad LLM lsass.exe LTM Memory Optimization Mentorship Microsoft Migration Multi-Region Keys NACL Native AOT Network Architecture Networking NIST ODBC Open Source Payment Cryptography Payments PCI Compliance Performance Platform Platform Architecture Power Tools PowerShell Python re:Invent Reachability Analyzer Redshift Relationships List Replace Root Volume SAA-C00 SAP-C00 Security Security Group Serverless SES SharePoint SharePoint 2010 Site Reliability SMTP Snapshot Software Engineering Solutions Architect Solutions Architect Professional SP 2007 SPAWAR SSL STIG Storage Strategy Sydney SysAdmin Team Foundation Server Team Utilities Tech Industry Technical Depth Technology TFS Tools Troubleshooting Upgrade Visual Studio VPC VPC Flow Logs Web Development WebPart WinDirStat Windows Server Windows Server 2025 WinForms