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.wordpress.com/2011/09/26/sharepoint-designer-workflow-fired-twice-in-a-migrated-list/
# 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)
}