Update Wrong Old URL in SharePoint Alerts on SharePoint Migration or URL Change

After upgrading from MOSS 2007 to SharePoint 2010, existing SharePoint alerts stopped working and only newly created alerts worked!!! We got to Fix Alerts after SharePoint migration, manually.

Tried these trial and errors:

  • Tried editing existing alerts, just changed its Name, It worked!
  • Tried Turning Individual Alert ON and OFF – Yes, Worked! but I’ve some 1000+ alerts for a Large web application. How about PowerShell?

PowerShell to Update Alerts in SharePoint:

$SPSite= Get-SPSite "https://mySharePoint.com/sites/alerts/"

foreach ($spweb in $SPSite.AllWebs)
	foreach($alert in $spweb.Alerts)
		$OriginalTitle = $alert.Title
		$alert.Title = "UPDATE: $OriginalTitle"

		$alert.Title = $OriginalTitle
		Write-Host "Updated Alert" $alert.Title "in"$spweb.url

But wait, the problem is not fully solved. From the Alert mails fired from the alerts created in MOSS 2007, URLs in the Alert mail is still pointing to OLD URL!

sharepoint 2010 email alerts wrong url

Fix SharePoint alerts Old URL Issue:
Again, PowerShell is a life saver. Use this script to Fix the wrong URLs in alerts and to fix the issue of “Old Alerts are not firing”

$SPSiteURL = "https://NewSharePoint.com/sites/alerts" #Site Collection Url 
$oldrooturl = "https://OldSharePoint.crescent.com" # Old URL of the webapplication
$rooturl = "https://NewSharePoint.com" # New URl for the new webapplication

$SPsite = Get-SPSite -Identity $SPSiteURL 
$SPwebs = $SPsite.AllWebs 

$updated = 0

foreach ($web in $SPwebs) #Get All the sub sites
	$alerts = $web.alerts  # Get All Alerts

	if ($alerts.count -ne 0)
		Write-Host -foregroundcolor green "Number of Alerts in: "$web.url ":" $alerts.count

		foreach ($alert in $alerts)
			#preserve & Change the Alert frequency, so that the so the datarow inside is touched by SharePoint API. 
			$Status = $alert.Status 
			$Frequency = $alert.AlertFrequency
			if($Frequency -eq [Microsoft.SharePoint.SPAlertFrequency]::Immediate)
				$alert.AlertFrequency = [Microsoft.SharePoint.SPAlertFrequency]::Weekly 
				$alert.AlertFrequency = [Microsoft.SharePoint.SPAlertFrequency]::Immediate 

			$title = $alert.title
			$alert.title = "UPDATED" + $title
			$alert.Status = [Microsoft.SharePoint.SPAlertStatus]::Off 

			$alert.Update()  #Update the modified values

			if ($alert.Properties -ne $null)
				if ($alert.Properties["siteurl"] -ne $null -and $alert.Properties["siteurl"].Contains($oldrooturl))
				$alert.Properties["siteurl"] = $alert.Properties["siteurl"].Replace($oldrooturl, $rooturl)
				if ($alert.Properties["mobileurl"] -ne $null -and $alert.Properties["mobileurl"].Contains($oldrooturl))
				$alert.Properties["mobileurl"] = $alert.Properties["mobileurl"].Replace($oldrooturl, $rooturl)

			#Reset the Values of alert, back to their original
			$alert.title = $title
			$alert.AlertFrequency = $Frequency 
			$alert.Status = $Status 

			write-host "Alert updated: " $title

		Write-Host "Number of alerts updated: " $updated

Not only during Migration, But this will help during changing the SharePoint URL also! Once you get a list of locations, Just Turn-Off and Turn-On the Incoming E-Mails settings of the Library.

In MOSS 2007, after moving to new URL you can simply run the “stsadm -o updatealert” command to update the alert mail’s URLs.

Update: Here is another script Invoke-AlertFixup which is equivalent to UpdateAlert operation: https://gallery.technet.microsoft.com/ScriptCenter/877d2abd-fce9-4545-b223-7637936dd888/

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. Passionate about sharing the deep technical knowledge and experience to help others, through the real-world articles!

5 thoughts on “Update Wrong Old URL in SharePoint Alerts on SharePoint Migration or URL Change

  • Thank you.

  • Really good information friend. Thanks for the post.

  • Great buddy u have save my time and effort…………….Go for it guys!!!!!!!

  • Hi Salaudeen,
    I’ve applied the above 1st script (line 1-16) to update Alert Title but still not getting alerts for existing alerts (the ones migrated from 2007). However newly created (in 2010) alerts are working.

    When I looked at the [ImmedSubscriptions] table, I found SiteURL was still showing the old web app. I tried few other scripts but nothing seems to get my existing alerts working. Until I ran Update command directly (per below link) into the table to change the SiteURL to my new web app URL. Alerts are not working but I know it’s not supported way. Do you have any suggestion why SiteURL not updating even after I’m running your first script?

    Thank you in advanced for any suggestion!


  • Nice post…keep your work up..i will visit ur site regularly..good work.discover pleasant and valuable information.

    Showing your skills set and good stuff.


Leave a Reply

Your email address will not be published. Required fields are marked *