Sunday, March 29, 2015

Fixing SharePoint 2010 Calendar Overlays After a Move with PowerShell

Posted in [SharePoint], [Technical] By Kyle Wright @ 1/29/2013

I was moving a site from production to development today and was welcomed to my new site with the following lovely message from SharePoint:


(The Web application at http://intranetprod/RA could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.)

So, if you have ever moved a calendar from one place to another, either as part of a site move or a list move, you will be greeted by the fact that your calendar overlays no longer work because the URLs to the overlaying calendars are hardcoded into the list view.  This calendar had 3 overlays and there are other calendars with more overlays.  I am trying to set up an automated restore from production to development, so having lots of broken calendars isn’t great.  Fortunately, all you have to do is run a few lines of PowerShell to fix this. 

I’ll walk you through the steps, the full code is below.

  1. Connect to the web in question.  You could very easily have this step through all webs in a site collection to update all your lists at once.
  2. Get your list.  Again, this could easily get all lists and look for calendars to update
  3. Get your view.  This assumes your view is called “Calendar” which is the default.  You could update it to be whatever your view is called.
  4. Get the CalendarSettings property of the view.  This is where the links are stored for the overlay.
  5. Then, just use the PowerShell replace command to replace your old URL with the new one.
  6. Apply the changes back to the property and update the view to save changes.

So, here is the full script.  Hope this helps.

   1:  #Add SharePoint PowerShell SnapIn if not already added 
   2:  if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) { 
   3:      Add-PSSnapin "Microsoft.SharePoint.PowerShell" 
   4:  }
   6:  $web = Get-SPWeb “http://intranetdev” 
   7:  $mainCalendar = $web.Lists["Calendar"] 
   8:  $view = $mainCalendar.Views["Calendar"]
  10:  $calSettings = $view.CalendarSettings 
  11:  $view.CalendarSettings = $calSettings.Replace("intranetprod", "intranetdev") 
  12:  $view.Update()



, ,


Got something to say? Join the discussion »
    Posted by Jeff Parker on 10/28/2014
    That was an awesome life-saver. Saved me tons of time from having to rebuild the entire calendar on the development site. Now I am able to quickly test some things out on the dev web app.
    Posted by Nizam on 2/5/2014
    This excellent post, this has helped us to resolve issue in production. Thanks alot buddy!!
    Posted by Ronnie Swafford on 12/20/2013
    Thanks for posting this! It's a common problem when doing a migration and there aren't many articles out there explaining it.

leave a reply

 [Quick Submit with Ctrl+Enter]

Remember my details
Notify me of followup comments via e-mail


About C5 Insight

We are a Microsoft Gold Certified partner focusing on SharePoint, Microsoft Dynamics CRM and  Learn more about us by visiting our website.


We Wrote the Bible on Microsoft SharePoint and Dynamics CRMBook-Microsoft Dynamics CRM 2011 and SharePoint 2010 Bible



Recent Comments


Blog Roll



The information herein may be used solely at your own risk.  No warranty is made by the author or by C5 Insight, Inc.

The opinons expressed herein are those of the individual authors and do not necessarily represent C5 Insight, Inc in any way.

Copyright 2011-2013 by C5 Insight