Click here to Skip to main content
15,879,239 members
Articles / Productivity Apps and Services / Sharepoint
Tip/Trick

Sharepoint PowerShell - Delete alerts from list

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
19 Sep 2011CPOL 21.6K  
Delete all alerts for a specific list or library on SharePoint.

To delete all alerts assigned in a list or library, we need to specify the web address and the list/library name.


JavaScript
function deleteAlerts(){
    $w = read-host "Web Address"
    $l = read-host "List Name"    
    $web = get-spweb $w
    $list = $web.lists[$l]
    $IDS = ""
    foreach($alert in $web.alerts)
	{
	    if($alert.ListID -eq $list.ID)
	    {
		$IDS += $alert.ID.tostring() + "|"
	    }
	    write-host -nonewline "*"
	}
    write-host "deleting..."
    foreach($s in $IDS.Split("|"))
    {
	write-host -nonewline "*"
	$web.alerts.delete([GUID]$s)
    }
}

deleteAlerts

Atention: After you run the script, the object $web could still have the alerts in memory. To be sure that the script runs successfully, open the alerts on SharePoint Web API: Site Actions -> Site settings -> Site Administration -> User Alerts.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Martifer Inovação e Gestão
Portugal Portugal
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --