Archive

Archive for March, 2014

Fixing: This page is not using a valid page layout. To correct the problem edit page settings and select a valid page layout error in SharePoint 2010

March 28, 2014 19 comments

I recently ran into the error below when I tried to access a Wiki Page after I migrated over a SharePoint 2010 Enterprise Wiki Site from one location to another.

This page is not using a valid page layout. To correct the problem edit page settings and select a valid page layout.

This sometimes happens after a migration of SharePoint Publishing Site Pages because the page layout URL is “hardcoded” into the  aspx pages, and if you migrated from one location to another the possiblity of that page layout not exiting or is incorrectly listed in your page will throw this error.  SharePoint is not smart enough to update this.

If you were to download a copy of that page and open it up you would see that the URL for the PublishingPageLayout is “hardcoded” with the “old” or “non existing” page layout.  Look for the <tag>:

<mso:PublishingPageLayout msdt:dt=”string”>URL to Publishing Page Layout</mso:PublishingPageLayout>

You will see that the URL is more than likely pointing back to the location it was migrated from.

Now you can simply just edit this URL to point to the corrrect location, save it, and then re-upload it back into the library, but who wants to do that for every single Page?

Below is a PowerShell script I used to fix my issue with the Wiki Pages.  It will iterate through all the Pages in the Publishing Pages library, check to see if the Pagelayout URL is incorrect, fix it, and check the page back in.

——————————————————————————————————————

#GET WEB
$web = Get-SPWeb -Identity http://portal-new/site/wiki

$pubWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
$spPages = $pubWeb.PagesLists;

#STORE MASTERPAGE LOCATION FOR ENTERPRISE WIKI INTO $PAGELAYOUT VARIABLE
$pageLayout = “/_catalogs/masterpage/EnterpriseWiki.aspx”

#STORE MASTERPAGE FOR ENTERPRISE WIKI NAME INTO $PAGELAYOUTNAME VARIABLE
$pageLayoutName = “Basic Page”

#LOOP THROUGH THE ITEMS OF THE WIKI PUBLISHING PAGES TO GRAB PAGE LAYOUT URL
foreach ($item in $spPages.Items)
{

$pubPage = [Microsoft.SharePoint.Publishing.PublishingPage]::GetPublishingPage($item)
$pubUrl = New-Object Microsoft.SharePoint.SPFieldUrlValue($pubPage.ListItem[[Microsoft.SharePoint.Publishing.FieldId]::PageLayout].ToString())

if ($pubUrl -ne $null)
{
$itemPubUrl = $pubUrl.Url

#IF PAGE LAYOUT URL IS INCORRECT, UPDATE PAGE LAYOUT URL, COMMIT CHANGES, AND CHECK PAGE IN.
if ($itemPubUrl -like http://portal-old/site/wiki*)
{
$newPubUrl = New-Object Microsoft.SharePoint.SPFieldValue(http://portal-new/site/wiki + $pageLayout, $pageLayoutName)

$pubPage.Name

Write-Host “Updating PageLayout for ” $pubPage.Name -foregroundcolor Yellow

$pubPage.CheckOut()
$pubPage.ListItem[[Microsoft.SharePoint.PublishingFieldId]::PageLayout] = $newPubUrl
$pubPage.ListItem.UpdateOverWriteVersion()
$pubPage.ListItem.File.CheckIn(“Fixed URL To Page Layout.”, [Microsoft.SharePoint.SPCheckinType]::MajorCheckIn);

}
}
}
——————————————————————————————————————–

After executing the script all the Page Layout URL’s should be updated to point to the correct Page Layout and you should no longer get that error.

Updating SharePoint 2010 Document Libraries Custom Send To Location URL using PowerShell

March 24, 2014 Leave a comment

I recently went  through the painful process of migrating/upgrading our Microsoft CRM/TMT SharePoint 2007 Web Application to SharePoint 2010.  In doing so I had to migrate from one domain to another.  With CRM/TMT there are literally thousands of sites with thousands of document libraries which are created dynamically through CRM.  Since most of all the document libraries within CRM utilize Custom Send To Locations I needed to update all document libraries to point to the new domain URL location.  Below is the PS script I generated to loop through all Site Collections/Webs/ and Document libraries to update the Custom Send To Locations.

————————————————————————————————————————————————————————————————————————–

$webapp = Get-SPWebApplication “http://crm2010&#8221;
foreach ($s in $webapp.Sites)
{

Write-host $s.Url
foreach ($web in $s.AllWebs)
{

Write-Host $web.ServerRelativeURL

foreach ($list in $web.Lists)
{

if ($list.BaseType -eq “DocumentLibrary”)

{

if ($list.Title -eq “Public Workspace” -or $list.Title -eq “Response Documents” -or $list.Title -eq “Original Documents”)

{

#Get $list.SendToLocationName and stores it in $SendToLocationName variable
$SendToLocationName = $list.SendToLocationName;

#Sets $list.SendToLocationName to $SendToLocationName variable value.
$list.SendToLocationName = $SendToLocationName;

Write-Host $SendToLocationName;

#Store $list.SendToLocationURL in $replaceURLstring variable.
$replaceURLstring = $list.SendToLocationUrl;

#Sets $list.SendToLocationURL to new URL.  Replacing crmsp2007 with crmsp2010
$replaceURLstring = $replaceURLstring.Replace(“crmsp2007″,”crmsp2010”);
$list.SendToLocationURL = $replaceURLstring;

Write-Host $replaceURLstring;

#Update List$list.Update()

}

}

}

}

}