Fix Broken Alerts After a SharePoint 2007 to 2010 Migration

So after performing a DB attach upgrade for a client, I found that all the Alerts they had setup were broken.
Well, hello PowerShell, can you help me? (That's a silly question).

The following is a script I used via SharePoint Management Shell as an Administrator to retrieve a list of alerts for the entire Site collection: http://portalnew


Get Alerts for site collection:
Get-SPweb -site http://portalnew -limit all | ForEach-Object {$_.alerts|foreach-object{write-host $_.user $_.properties["siteUrl"] $_.properties["dispformurl"]}}

After performing the above script, I saw a handful of alerts looking for the old server name. The below script updates the server name for all alerts needing the update:

Update URL for broken alerts:
Get-SPweb -site http://portalnew -limit all | ForEach-Object {$_.alerts|foreach-object{$_.properties["siteUrl"] = "http://portalnew";$_.update()}}

Have fun with that!