Copy Alerts from One SharePoint List or Library to Another using PowerShell

Requirement: Copy Alerts from one SharePoint list to another list.

Solution: Use this PowerShell script to copy alerts between SharePoint lists or libraries.

My scenario is: We have a list with a number of alerts created for various users. We copied that list to a new site through “Save list as template,” and the requirement of copying alerts came!

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

function Copy-SPAlerts($SourceWebUrl,$SourceList, $TargetWebUrl, $TargetList)
{
    #Get the source Web & List objects
    $SourceWeb = Get-SPWeb $SourceWebUrl
    $SourceList= $SourceWeb.lists.TryGetList($SourceList)   

    #Get the Target Web & List objects
    $TargetWeb = Get-SPWeb $TargetWebUrl
    $TargetList= $TargetWeb.lists.TryGetList($TargetList)   
 
    #Get All Alerts of the Source list
    $SourceAlertsColl = $SourceWeb.Alerts | Where-Object { ($_.List.Title -eq $SourceList.Title)}
    
    write-host Found $SourceAlertsColl.count alerts in the source List!

    if($SourceAlertsColl.Count -gt 0)
    {
        foreach ($SourceAlert in $SourceAlertsColl)
        {
            #Copy alerts from source to destination
            $alert = $TargetWeb.Alerts.Add()
            $alert.Title = $SourceAlert.Title
            $alert.AlertType = [Microsoft.SharePoint.SPAlertType]::List
            $alert.User = $SourceAlert.user 
            $alert.List = $TargetList
            $alert.DeliveryChannels = $SourceAlert.DeliveryChannels
            $alert.EventType =  $SourceAlert.EventType
            $alert.AlertFrequency = $SourceAlert.AlertFrequency
            $alert.Update()

            Write-Host "Copied Alert: $($SourceAlert.Title)" -foregroundcolor Green
        }
    }

}

#Variables
$SourceWebURL="https://intranet.crescent.com/PMO"
$SourceListName="Project Documents"
$TargetWebURL="https://intranet.crescent.com/sites/projects/BI/"
$TargetListName="Project Documents"

#Call the function to Copy Alerts
Copy-SPAlerts $SourceWebURL $SourceListName $TargetWebURL $TargetListName

Remember, when you copy alerts from one list to another, it triggers “New Alert Created” E-mail as:

Copy Alerts from One List to Another List in SharePoint

You can disable alerts for the time being before copying: How to Disable Alerts in SharePoint List or Library?

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

5 thoughts on “Copy Alerts from One SharePoint List or Library to Another using PowerShell

  • will the Quest Metalogix migration tool migrate the alert from SP2013 to SP online

    Reply
  • Hi Again –
    Just tested your script for disabling alerts for a specific list. This won’t help with the newly created alerts, right? Seems like it only disabled existing alerts.

    Thanks for any feedback Salaudeen!

    Reply
  • Wonderful! Million thanks Salaudeen!! I tested your script yesterday and it works perfect!

    I know you already mentioned about the message users will be getting once the new alerts are created. is there anyway to stop that? I thought I could just remove Outgoing SMTP server or set “alerts-enabled to false” and not have those messages sent but realized that won’t even copy the alerts over. Appreciate any feedback you may have on this!

    Again this script is very helpful!

    Reply

Leave a Reply

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