There is a bug in SharePoint list view property "CalendarSettings". When a site collection is restored to another web application or farm, the web URL in "CalendarSettings" still points to the previous web. The URL should be server relative, but unfortunately it's an absolute path.
(My test environment is SharePoint 2010 SP2 + CU201308, and the problem is still there.)
Thanks to the PowerShell script from Paul Ewert, we can fix the problem easily. The scripts are pretty good, and I don't see any problem there.
Below is the scripts, just to make it easier to maintain:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction "SilentlyContinue"
cls
# http://spsawyer.wordpress.com/2013/07/11/sharepoint-calendar-overlay-not-found-errors/
function FixCalendarSettings([string]$oldWebApplicationURL, [string]$currentWebApplicationURL)
{
write-host "Updating CalendarSettings..."
Start-SPAssignment –Global
write-host $views.Count " views update start...";
$views = New-Object System.Collections.ArrayList
$webApp = Get-SPWebApplication $currentWebApplicationURL
foreach ($site in $webApp.Sites)
{
Write-Host "site URL: " $site.Url
foreach($web in $site.AllWebs)
{
Write-Host "web URL: " $web.Url
foreach($list in $web.Lists)
{
foreach($view in $list.Views)
{
if ($view.CalendarSettings -ne $null -and $view.CalendarSettings -like '*'+$oldWebApplicationURL+'*')
{
$views.Add($view)
}
else
{
Write-Host -NoNewline ".";
}
}
}
Write-Host "";
}
}
foreach($view in $views)
{
$view.CalendarSettings = $view.CalendarSettings.Replace($oldWebApplicationURL, $currentWebApplicationURL);
$view.Update();
Write-Host "View " $view.ServerRelativeUrl " updated." -ForegroundColor Yellow;
}
write-host $views.Count " views updated.";
Stop-SPAssignment –Global
}
FixCalendarSettings "http://webapp1" "http://webapp2"
Write-Host "Finished! Press enter key to exit." -ForegroundColor Green
Read-Host
No comments:
Post a Comment