Delete the alerts from the site using SharePoint 2010 web service in powershell

 

Navigate to the SharePoint site. Go to Site Actions, and then click on Site Settings. In the Site Administration section, click on User Alerts. Select the user from the drop down and then click on Update button. You could be able to view all the alerts for the selected user. In this you will see how to delete those alerts.


 

Steps Involved:

  1. Open SharePoint 2010 Management Shell by going to Start | All Programs | SharePoint | Microsoft SharePoint 2010 Products | SharePoint 2010 Management Shell (Run as Administrator).
  2. Run the following script.

Powershell Script:

 
 
## Delete the alerts for a particular user from the site using SharePoint 2010 web service in powershell
$uri="http://serverName:10736/sites/ECT2/_vti_bin/Alerts.asmx?wsdl"

$credential=Get-Credential
## Web Service Reference - http://Site/_vti_bin/Alerts.asmx
$alertsWebServiceReference = New-WebServiceProxy -Uri $uri -Credential $credential
$alertInfo=$alertsWebServiceReference.GetAlerts()
[
String[]] $deleteAlert = New-Object -TypeName System.String -ArgumentList $alertInfo.Alerts.Length
[
int]$count=0
foreach($alert in $alertInfo.Alerts)
{
$deleteAlert[$count]=$alert.Id.ToString()
$count++
}
$alertsWebServiceReference.DeleteAlerts($deleteAlert)





Ebook Download
View all
Learn
View all