问题
Made a Wiki Page Library (not the publishing wiki) and can add pages with content like below, but when the page renders there is no SharePoint Chrome, just my content shows up. here is code. I it seems there may be one more property to add so master page takes effect?
$FileCreationInformation = New-Object Microsoft.SharePoint.Client.FileCreationInformation
$FileCreationInformation.Url = $FileRef
$FileCreationInformation.Overwrite = $true
$FileCreationInformation.Content = [System.Text.Encoding]::UTF8.GetBytes($HTMLPageContent)
$wikiFile = $WikiPageList.RootFolder.Files.Add($FileCreationInformation)
$ClientContext.Load($wikiFile)
$ClientContext.ExecuteQuery()
回答1:
How to create a page in Wiki Page Library using CSOM in SharePoint 2013
Use Utility.CreateWikiPageInContextWeb method to create a page in Wiki Page Library
:
Function Create-WikiPage([Microsoft.SharePoint.Client.ClientContext]$Context,[string]$WikiLibraryTitle,[string]$PageName,[string]$PageContent)
{
$wikiLibrary = $Context.Web.Lists.GetByTitle($wikiLibraryTitle)
$Context.Load($wikiLibrary.RootFolder)
$Context.ExecuteQuery()
$wikiPageInfo = New-Object Microsoft.SharePoint.Client.Utilities.WikiPageCreationInformation
$wikiPageInfo.WikiHtmlContent = $PageContent
$wikiPageInfo.ServerRelativeUrl = [String]::Format("{0}/{1}", $wikiLibrary.RootFolder.ServerRelativeUrl, $PageName)
$wikiFile = [Microsoft.SharePoint.Client.Utilities.Utility]::CreateWikiPageInContextWeb($Context, $wikiPageInfo)
$context.ExecuteQuery()
}
Usage
$context = New-Object Microsoft.SharePoint.Client.ClientContext($Url)
Create-WikiPage -Context $Context -WikiLibraryTitle "KBList" -PageName "Welcome.aspx" -PageContent "Welcome to the SharePoint!"
$context.Dispose()
来源:https://stackoverflow.com/questions/26789829/add-wiki-page-library-pages-not-the-publishing-wiki-with-powershell-csom-share