Update alerts by using Windows PowerShell

Windows PowerShell script that

 
 
 
 
 
3.5 Star
(21)
Add to favorites
SharePoint
9/22/2010
E-mail Twitter del.icio.us Digg Facebook
  • nothing happens, when I run the script
    2 Posts | Last post June 22, 2015
    • Dear Kirk,
      
      Thank you for writing this valuable script. For some reason when I run it, nothign happens, no print out or anything. I am running Sharepoint Management shell as an admin, I'm the DB owner and security admin. What could I be doing wrong? 
      
      i'm running the following: Sire collection and oldURL happen to be the same. We basically have one massive site collection, and it's used for external users, they always receive the internal URL, even though the URL mapping is setup to use our extranet URL. I would like to change that all Alert URLs point to our Extranet URL.
      
      PS C:\sp> .\Invoke-AlertFixup.ps1 -site "http://site" -oldurl "http://site" -whatif
      
      Thank you in advance!
      
      Vlad
    • Vladikt, 
      Please follow this blog :http://blogs.technet.com/b/saantil/archive/2010/12/04/invoke-alertfixup.aspx
      
      You will need to run the script using :
       It is  period space period /Invoke-AlertFixup.ps1
  • Bug Report - Double path entry
    3 Posts | Last post August 21, 2014
    • Kirk, Thanks for the script. Overall it works well however I did run into an issue when running it against a site collection. The old site collection locations was http://oldlocation/sites/technology and the new site was http://newlocation.domain.org/sites/technology. After running the script, I ended up with links in the Alert email (Modify my alert settings, documentlink, & View <document library>) that included the path to the site collection twice. In other words, the link for Modify my alert settings was: http://newlocation.domain.org/sites/technology/sites/technology/Projects/_layouts/MySubs.aspx.
      
      I tweaked your script a litte and added a WebApp parameter that takes the URL of the Web Application, and the modified the line: $NewUrl = $Site.SiteUrl to read $NewUrl = $WebApp. After that I ran it again using the bad new link as the old link and the alerts links were updated correctly.
      
      -Kevin
      
    • We faced this issue. I did few changes in the script. Check the details here:http://social.technet.microsoft.com/Forums/en-US/sharepointgeneralprevious/thread/1ad3e636-a2bf-4da1-9d6f-4db6e5b19d19/
      
    • Kevin... Same thing happened to me.   The corrected Url of http://site.com/teams/xxx  is now http://site.com/teams/xxx/teams/xxx in my alert,
      
      I tried your suggestion of replacing the $Site.SiteUrl with $WebApp but the script doesn't seem to update and generates errors where it didn't before. IS there more code I need to adjust or add? Will this fix the double entry issue when adjusted?
      
      Pradip....
      I tried your script... even replaced the "/sites" with the appropriate "/xxx" in my url but I doesn't fix the links, just says "0 fixed".
      
      Any help you guys can provide would be saving me from losing my mind!
  • Double Path Entry
    1 Posts | Last post August 20, 2014
    • Kevin... Same thing happened to me.   The corrected Url of http://site.com/teams/xxx  is not http://site.com/teams/xxx/teams/xxx in my alert,
      
      I tried your suggestion of replacing the Site.SiteUrl with WebApp but the script doesn't seem to update and generates errors where it didn't before. IS there more code I need to adjust or add? Will this fix the double entry issue when adjusted?
  • No URLs are corrected when running this script, any help?
    2 Posts | Last post May 24, 2013
    • Not sure whether Kirk monitors these questions as I've not seen any response to the questions already posted. Still I'm posting this here hoping someone else may have the answer. :-)
      
      When I execute 'Invoke-AlertFixup' I get the following message and obviously no URLs being corrected and upgraded subscriptions from 2007 not working. Details can be found here. Any suggestion anyone? 
      
      Many thanks in advanced!
      
      Scanning Alerts for http://siteurl/collaboration/connect
        = 0 alerts for subweb Connect,http://siteurl/collaboration/connect
            Alerts Fixed: 0
        = 0 alerts for subweb Marketplace,http://siteurl/collaboration/connect/marketplace
            Alerts Fixed: 0
        = 22 alerts for subweb subsite Marketplace,http://siteurl/collaboration/connect/marketplace/subsite
            Alerts Fixed: 0
            Alerts Skipped (Zone): 22
        = 2 alerts for subweb Learning Solutions Blog,http://siteurl/collaboration/connect/lsblog
            Alerts Fixed: 0
      
    • sorry missed the URL I referred: http://social.msdn.microsoft.com/Forums/en-US/sharepointadminprevious/thread/c8be3dd4-76c1-4f69-9039-9ae03434175f
  • Alert frequency incorrect
    1 Posts | Last post March 18, 2013
    • Just reading through this code, not actually running it. It appears it will set reset the alert frequency incorrectly.  Please review before running!
  • Why such complicated?
    1 Posts | Last post January 10, 2013
    • Why do we need to preserver & write it back to the Alerts?
      Wouldn't it be easier using following Code? Or am I missing something? 
      
      Add-PsSnapin Microsoft.SharePoint.PowerShell -erroraction silentlycontinue 
      
      
      $webapp = Get-SPWebApplication http://sharepoint
      
      $newurl = "http://sharepoint"
      
      $oldurl = "http://oldsharepoint"
      
      
      foreach ($site in $webapp.sites)
      
      {
      
      foreach ($web in $site.AllWebs) 
      		
      {
      
      
      
      	    Write-Host -ForegroundColor Yellow "Scanning Alerts for $site"
      
      			
       
      	Write-Host ("  = "+($web.Alerts.Count.ToString())+" alerts for subweb "+($web.Title)+","+($web.URL))
      
          		foreach ($alert in $web.Alerts) 
      		
      		{
             write-host $alert.Title $alert.AlertFrequency $alert.properties["siteURL"]
      
      			if($alert.properties["siteURL"] -eq $oldurl)
      			{
      			$alert.properties["siteURL"] = $newurl
      			$alert.update();
      			}
      
      		}
      
      
      
      
      }
      }
      $site.Dispose()
      $web.Dispose()
  • Suggestion - SPWeb Disposal
    1 Posts | Last post September 27, 2011
    • Kirk, please consider adding disposal code to your script for SPWeb objects. As a suggestion for good practice, call dispose directly create a SPAssignment that gets stopped for each SPWeb object. Cheers. C.