I was recently doing some troubleshooting for a SharePoint/TFS Environment that changed from HTTP to a secure environment of HTTPS.  That caused several issues for SharePoint, but one of the issues was the fact that all of the existing sites still had the old URL in them for the SharePoint alerts.  Hmmm….How do we fix that?

Well, first, I tried the old STS Command:

stsadm -o updatealert -url http://yournewurl -oldurl http://yournewurl

However, the command would not work.  It appears that this command has been deprecated in SharePoint 2013.  Stsadm should not be used anyways.

The solution I found that worked, I found over here: http://akforsharepoint.blogspot.com/2013/04/sharepoint-alerts-email-showing-wrong.html

The actual script is:

$SPwebApp = Get-SPWebApplication "http://sites.mysharepoint.com"
foreach ($SPsite in $SPwebApp.Sites)
    {
        foreach($SPweb in $SPsite.AllWebs)
        {
           $alerts = $SPweb.Alerts
                        foreach($alert in $alerts)
                        {          
                                    if($alert.AlertFrequency -eq [Microsoft.SharePoint.SPAlertFrequency]::Daily)
                                    {
                                                $alert.AlertFrequency = [Microsoft.SharePoint.SPAlertFrequency]::Immediate
                                                $alert.Update()
                                                $alert.AlertFrequency = [Microsoft.SharePoint.SPAlertFrequency]::Daily
                                                $alert.Update()
                                    }
                                    ElseIf($alert.AlertFrequency -eq [Microsoft.SharePoint.SPAlertFrequency]::Immediate)
                                    {
                                                $alert.AlertFrequency = [Microsoft.SharePoint.SPAlertFrequency]::Daily
                                                $alert.Update()
                                                $alert.AlertFrequency =[Microsoft.SharePoint.SPAlertFrequency]::Immediate
                                                $alert.Update()
                                    }
                                    Else
                                    {
                                                $alert.AlertFrequency = [Microsoft.SharePoint.SPAlertFrequency]::Daily
                                                $alert.Update()
                                                $alert.AlertFrequency =[Microsoft.SharePoint.SPAlertFrequency]::Weekly
                                                $alert.Update()
                                    }
           
                       
                       write-host -f Green $alert.Title
                       "User Name    - " + $alert.User.Name
            "Title        - " + $alert.Title
            "Frequency    - " + $alert.AlertFrequency
            "Delivery Via - " + $alert.DeliveryChannels
            "Change Type  - " + $alert.eventtype
            Write-Host "=================================="
                        }
            }
  
}

This script doesn’t actually change anything, it simply updates the frequency to some other value and sets it back to their original one. This will force alerts to update its stored absolute URLs and fix the issues reported regarding that.

Now, you know the story is not done that simply right???  Well, I immediately got an Access Denied stating that the SharePoint Farm Admin account did not have access to the database.  This can’t be!!!  The Admin had denied the Farm Account access to the Content Databases for security.  Sigh, I granted DB_Owner and SPData_Access Roles.

The Farm Account also did not have access to the Web Application which I granted via Web Application Security Policy.  Finally – Success!!

About the author 

Joshua Davis, DesertedRoad