Click here to Skip to main content
Click here to Skip to main content

Sharepoint PowerShell - Delete alerts from list

, 19 Sep 2011
Rate this:
Please Sign up or sign in to vote.
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.

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)

Share

About the Author

brunofer2007
Software Developer (Senior) Martifer Inovação e Gestão
Portugal Portugal
No Biography provided

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 19 Sep 2011
Article Copyright 2011 by brunofer2007
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid