Pages

9/29/2013

SharePoint - Delete all alerts!

 

Need to clean out all of the alerts from a development or testing system? Here's a PowerShell script to delete alerts. Run at your own risk... This will delete all alerts in all subsites in all site collections in all web applications (including My Sites).

Did I say… "Run at your own risk"?  PowerShell scripts like this one can do real harm on a production system and should only be run on a development or testing system. 

 

So… Run at your own risk…  Smile

This should work in both SharePoint 2010 and 2013.

foreach ($site in Get-SPSite -Limit All) 
{ 
  "Site Collection $site" 
  foreach ($web in $site.allwebs)
  {
     "  Web $web"
     $c = $web.alerts.count
     "    Deleting $c alerts"
     for ($i=$c-1;$i -ge 0; $i--) { $web.alerts.delete($i) }
  }
}

1 comment:

Sandra de Palma said...

Hi Mike

I used this script to get rid of all the alerts (email subscriptions) on our test Sharepoint site, which is a copy of production.

We found that when we emtied all documents on the test site for confidentiality reasons, people were spammed with alerts. Thanks to your script, this does not happen any more.

Thanks a lot, it worked like a treat.

Sandra

Post a Comment

Note to spammers...
Spammers, don't waste your time... all posts are moderated. If your comment includes unrelated links, is advertising, or just pure spam, it will never be seen.