【问题标题】:Add Wiki Page Library pages (not the publishing wiki) with PowerShell CSOM SharePoint 2013使用 PowerShell CSOM SharePoint 2013 添加 Wiki 页面库页面(不是发布 wiki)
【发布时间】:2014-11-06 21:36:18
【问题描述】:

制作了一个 Wiki 页面库(不是发布 wiki),并且可以添加具有如下内容的页面,但是当页面呈现时,没有 SharePoint Chrome,只有我的内容显示。这是代码。我似乎还需要添加一个属性以便母版页生效?

$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() 

【问题讨论】:

    标签: powershell sharepoint


    【解决方案1】:

    如何在 SharePoint 2013 中使用 CSOM 在 Wiki 页面库中创建页面

    使用Utility.CreateWikiPageInContextWeb methodWiki 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()   
    }
    

    用法

    $context = New-Object Microsoft.SharePoint.Client.ClientContext($Url)
    Create-WikiPage -Context $Context -WikiLibraryTitle "KBList" -PageName "Welcome.aspx" -PageContent "Welcome to the SharePoint!"
    $context.Dispose()
    

    【讨论】:

    • 瓦迪姆你是个传奇。谢谢你。如果未使用 Add-Type 加载 Microsoft.SharePoint.Client.dll 和 Microsoft.SharePoint.Client.Runtime.dll,此代码将引发消息 New-Object : Cannot find type [Microsoft.SharePoint.Client.ClientContext]: verify that the assembly containing this type is loaded.
    猜你喜欢
    • 1970-01-01
    • 2011-04-07
    • 2023-03-11
    • 2015-12-12
    • 2014-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多