0

Wondering if there is a Powershell script to copy all subscriptions over from one list to another list. I've a situation where user re-created a list to under a subsite and would like to copy all old user alerts to the new list. There are quite few (over 1k :-)) immediate and scheduled subscription in the old list. Therefore it is preferred to avoid asking users to redo the subscriptions.

Old list url something like: http://siteurl/subsite/list new url: http://siteurl/subsite/subsubsite/list

Questions:

  1. Once the new alerts are created through PS - would the user get a notification saying they are subscribed to the new URL? If so can this be avoided?
  2. Any reference as how to removed the old list subscriptions once they are copied over?
  3. Scrip would copy Immediate/ Scheduled subscription settings correctly? for example if someone had a setting to get immediate alert right away for anythings changes vs changes done to his/ her items etc.

Found references here and also there but could not get these to customize to the current need (not a great coder) :-(.

0

Based on my request on the 2nd link above Salaudeen put a script together here. Hope this helps others! Credit goes to him!

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="http://intranet.crescent.com/PMO"
$SourceListName="Project Documents"
$TargetWebURL="http://intranet.crescent.com/sites/projects/BI/"
$TargetListName="Project Documents"

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.