Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I understand alerts will only be show to those who created them.

However I am on a test site and would like to rid the list of all alerts.

Is there a way to do this programatically.

I can seem to list them out using the following script:(See below error)

When I tried including a $web.Alerts.Delete() in the for block it throws me an error

(Cannot find an overload for "Delete" and the argument count: At C:\Users\spfarm\desktop\Alerts.ps1:14 char:19 + $web.Alerts.Delete <<<< (); + CategoryInfo : NotSpecified: (:) [], MethodEx + FullyQualifiedErrorId : MethodCountCouldNotFindBest)

$web = Get-SPWeb "http://SharepointTest:2000/"
$listurl = "http://sharepointTest:2000/Lists/Announcements/"

foreach($alert in $web.Alerts)
{
#if($alert.ListUrl -eq $ListUrl)
#{ 
 "User - " + $alert.User.Name
 "Title - " + $alert.Title
 "Frequency - " + $alert.AlertFrequency
 "Delivery Via - " + $alert.DeliveryChannels
 "Change Type - " + $alert.eventtype
 Write-Host "_____________________"

#}
}
share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

According to the Microsoft Documentation, there is no .Delete() method on the SPAlertsCollection that takes no parameters. It appears that the method requires you to iterate through the alerts and then delete each one by passing the alert unique ID to the .Delete(GUID) method

share|improve this answer
    
Yup looks like that! Thanks –  user7400 Jul 18 '12 at 19:21
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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