2015-03-10

With the recent time change for Daylight Savings Time, I am reminded that it is time to run some scripts that will update the time stamps for alerts.

Problem: When alerts are set for a list or library, they can be scheduled to be sent immediately or as a daily or weekly summary sent at a specific day and time. When the time changes, the time in the alert is not updated. 

Solution: It is necessary to turn the alert off, then back on again. This resets the internal time for the alert.

Process: First you need to find all of your alerts. The location of your alerts can be verified by using the following PowerShell script, which outputs all of the alerts created on the farm:

$credential = Get-Credential -Credential domain\name

$session = New-PSSession -cn [name] -Credential $credential -Authentication Credssp

function get-allalerts(){

    [void][System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”)

    $farm = [Microsoft.SharePoint.Administration.SPFarm]::Local

    foreach ($spService in $farm.Services) {

        if (!($spService -is [Microsoft.SharePoint.Administration.SPWebService])) {

            continue;

        }

        foreach ($webApp in $spService.WebApplications) {

            #exclude Central Admin app

                                    if ($webApp -is [Microsoft.SharePoint.Administration.SPAdministrationWebApplication]) { continue }

                                    #exclude MySite

                                    if ($webApp -contains “MySite” ) { break }

            foreach ($site in $webApp.Sites) {

                foreach ($web in $site.AllWebs) {

                                                            foreach ($user in $web.SiteUsers)

                                                            {

                                                                        foreach($alert in $user.Alerts)

                                                                        {

                                                                        $lstitemurl = “”

                                                                                    if($alert.AlertType -eq “Item”)

                                                                                    {

                                                                                    $list = $alert.List

                                                                                    $lstitem = $alert.Item

                                                                                    $lstitemtitle = $lstitem.Title

                                                                                    }

                                                                                    $data = @{

                                                                                                            “WebURL” = $web.URL

                                                                                                            “User” = $user.LoginName

                                                                                                            “Alerttitle” = $alert.Title

                                                                                                            “AlertFrequency” = $alert.AlertFrequency

                                                                                                            “AlertType” = $alert.AlertType

                                                                                                            “AlertList” = $list.Title

                                                                                                            “AlertitemTitle” = $lstitemtitle

                                                                                                }

                                                                                                New-Object PSObject -Property $data

                                                                        }

                                                            }                                             

                                                }

                                    }

                        }

            }

}

get-allalerts | Export-Csv -NoTypeInformation -Path “d:\temp\allalerts.csv”

Once the correct location is determined, run the following PowerShell script found here, which turns off the alerts, then turns them back on, which resets the time.

Don’t forget to set a reminder for yourself to do this every time the time changes.

About the author 

Darrell Houghton

MCSE and MOS certified in SharePoint 2013. SharePoint power user, evangelist, and teacher. In-depth knowledge of out-of-the-box SharePoint functionality, best practices, business workflows, and site architecture.