Skip to content

Instantly share code, notes, and snippets.

@ronmichael
Created April 10, 2013 21:10
Show Gist options
  • Save ronmichael/5358458 to your computer and use it in GitHub Desktop.
Save ronmichael/5358458 to your computer and use it in GitHub Desktop.
After migrating from SharePoint 2010 to 2013 we found that some workflows ran multiple times. The cause was multiple event receivers left over on lists from SharePoint 2010. So we created this script to go through all the lists on all the sites on your server and remove the old SharePoint 2010 event receivers. Credits to http://sharelockpoint.wo…
# delete old SharePoint 2010 event receivers to eliminate duplicate workflow actions
function examineWeb($web) {
$spLists = $web.Lists;
for ($listnum=0; $listnum -lt $spLists.Count; $listnum+=1)
{
$($web.Title + " - " + $spList.Title)
$spList = $spLists[$listnum];
$changed = 0
for($ernum=0; $ernum -lt $spList.EventReceivers.Count; $ernum+=1)
{
$er = $spList.EventReceivers[$ernum]
if ($er.Assembly -eq "Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")
{
" Found & deleted"
$changed =1
$er.Delete()
}
}
if ($changed -eq 1) {
$spList.Update()
}
}
for($webnum=0; $webnum -lt $web.Webs.Count; $webnum+=1)
{
$web2 = $web.Webs[$webnum]
examineWeb($web2)
}
}
if ( $args.Count -eq 0 ) {
echo "Please provide the URL of the root"
}
else
{
$root = Get-SPWeb -Identity $args[0]
examineWeb($root)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment