TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Swetha
NA
196
25.9k
Err :“the given key was not present in the dictionary ” SPO
Sep 17 2018 12:59 AM
Hi,
I am unable to create a publishing page in any of the subsites,gettingerror:"the given key was not present in the dictionary". but able to create in site collection level.
Below is my Code:
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($ParentSiteurl)
$ctx.Credentials = $credentials
$ctx.ExecuteQuery()
$subsiteCtx = New-Object Microsoft.SharePoint.Client.ClientContext($subsiteUrl)
$subsiteCtx.Credentials = $credentials
$subsiteCtx.ExecuteQuery()
$pageLayoutList = $ctx.Web.Lists.GetByTitle("Master Page Gallery")
$ctx.Load($pageLayoutList)
$ctx.ExecuteQuery()
$pageLayoutQuery = New-Object Microsoft.SharePoint.Client.CamlQuery
$pageLayoutQuery.ViewXml = "
OneSmallOneLargeOneSmallColumnLayout.aspx
"
$pageLayouts = $pageLayoutList.GetItems($pageLayoutQuery)
$ctx.Load($pageLayouts)
$ctx.ExecuteQuery()
$pageLayout = $pageLayouts[0]
#Get the publishing Web
$pubWeb = [Microsoft.SharePoint.Client.Publishing.PublishingWeb]::GetPublishingWeb($subsiteCtx, $subsiteCtx.Web)
$subsiteCtx.Load($pubWeb)
$subsiteCtx.ExecuteQuery()
$pageInfo = New-Object Microsoft.SharePoint.Client.Publishing.PublishingPageInformation
$pageInfo.Name = $pageName
$pageInfo.PageLayoutListItem =$pageLayout
$page =$pubWeb.AddPublishingPage($pageInfo)
$subsiteCtx.Load($page)
$subsiteCtx.ExecuteQuery()
$PagesList = $subsiteCtx.Web.Lists.GetByTitle("Pages")
$subsiteCtx.Load($PagesList)
$subsiteCtx.ExecuteQuery()
$publishPage = $subsiteCtx.Web.GetFileByServerRelativeUrl($PagesList.ParentWebUrl + "/Pages/" + $pageName)
$subsiteCtx.Load($publishPage)
$subsiteCtx.ExecuteQuery()
$publishPage.CheckIn("Page Created", [Microsoft.SharePoint.Client.CheckinType]::MajorCheckIn)
$publishPage.publish("Publish")
$subsiteCtx.load($publishPage)
$subsiteCtx.ExecuteQuery()
Reply
Answers (
3
)
how to exclude listitem url from the search results
How to create mutiple views for sp list programmatically ?