Archive
Fixing pages and their layouts after importing a published site
If you export a publishing site from one farm and import it to another, you may be surprised that none of your pages will work. I recently got the following error:
The problem is the page is hard-coded to the page layout from the original site.
The following Powershell script that my buddy Raj wrote will fix the problem:
- function LoadSharePointPowerShellEnvironment
- {
- write-host
- write-host "Setting up PowerShell environment for SharePoint" -foregroundcolor Yellow
- write-host
- Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue
- write-host "SharePoint PowerShell Snapin loaded." -foregroundcolor Green
- }
- write-host
- LoadSharePointPowerShellEnvironment
- [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
- [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Publishing")
- $web = Get-SPWeb -Identity "http://myserver/sites/sales/wiki"
- $spPubWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
- $pages = $spPubWeb.PagesList
- foreach($item in $pages.Items)
- {
- $pubPage = [Microsoft.SharePoint.Publishing.PublishingPage]::GetPublishingPage($item)
- $url = new-object Microsoft.SharePoint.SPFieldUrlValue($pubPage.ListItem[[Microsoft.SharePoint.Publishing.FieldId]::PageLayout].ToString())
- if($url -ne $null)
- {
- $ss =$url.Url
- if($ss -match'TreeWikiLayout')
- {
- $newurl = new-object Microsoft.SharePoint.SPFieldUrlValue("http://myserver/sites/sales/_catalogs/masterpage/TreeWikiLayout.aspx, Enterprise Wiki Layout with Tree")
- $pubPage.Name
- $pubPage.CheckOut()
- $pubPage.ListItem[[Microsoft.SharePoint.Publishing.FieldId]::PageLayout] = $newurl
- $pubPage.ListItem.UpdateOverwriteVersion()
- $pubPage.ListItem.File.CheckIn("Fixed URL to page layout.", [Microsoft.SharePoint.SPCheckinType]::MajorCheckIn);
- }
- elseif($ss -match'EnterpriseWiki')
- {
- $newurl = new-object Microsoft.SharePoint.SPFieldUrlValue("http://myserver/sites/sales/_catalogs/masterpage/EnterpriseWiki.aspx, Basic Page")
- $pubPage.Name
- $pubPage.CheckOut()
- $pubPage.ListItem[[Microsoft.SharePoint.Publishing.FieldId]::PageLayout] = $newurl
- $pubPage.ListItem.UpdateOverwriteVersion()
- $pubPage.ListItem.File.CheckIn("Fixed URL to page layout.", [Microsoft.SharePoint.SPCheckinType]::MajorCheckIn);
- }
- }
- }
It’s a little odd that this issue was carried over from 2007 to 2010, but there you go….
SharePoint 2010 Setup unable to proceed due to a pending system restart
A recent install resulted in the following error:
“Setup is unable to proceed due to the following error(s): A system restart from a previous installation is pending.”
The problem was related to a registry key “PendingFileRenameOperations” located at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager.
Fix
Rename the key to PendingFileRenameOperations1 and you will be able to proceed with the install.