Home > SharePoint > SharePoint Page Layouts and Site Templates “The object specified does not belong to a list.”

SharePoint Page Layouts and Site Templates “The object specified does not belong to a list.”

SharePoint Version: SharePoint 2010, SharePoint 2013

Ever try and update the available page layouts for a site and get the following error:

 

“The object specified does not belong to a list.”

 

The chances are some page layout got deleted or corrupt and is blowing up this page. The following PowerShell will set the site so all page layouts are available and can get you past this issue.

 

<#
Reset site to use all page layouts
#>

param
(
    #required params
    [string]$webName  = $(throw "webName parameter not specified"),
    [string]$resetsubsites  = $(throw "resetsubsites parameter not specified")
)

if (-not (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue))
{
    Add-PSSnapin Microsoft.SharePoint.PowerShell
}
 
$web = Get-SPWeb $webName;
 
if ([Microsoft.SharePoint.Publishing.PublishingWeb]::IsPublishingWeb($web))
{
    $spPub = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
    $spPub.IsAllowingAllPageLayouts # check to see if it is already set
    $spPub.AllowAllPageLayouts($false) #Set it to allow all page layouts
    $spPub.Update()
}
else
{
    Write-Host $webName is not a publishing web.
}
 
$web.Dispose();

Advertisements
Categories: SharePoint Tags: ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: