2016-05-11 12 views
1

すべて、SharePoint OnlineのPowerShellのCSOMカスタムテンプレートからリストを作成

私はPowerShellとCSOMを使用してSharePoint Onlineのためのコンテンツを含むカスタムリストテンプレートを使用してリストを作成しようとしています。今のリストテンプレートは、既にサイトコレクションに読み込まれています。 UIを通過すると、コンテンツを含むテンプレートを使用して問題のないサイトでリストを作成できます。私がpowershellでそれをやろうとすると、リストは作成されますが、列やコンテンツは作成されません。

$clientContext = New-Object Microsoft.SharePoint.Client.ClientContext($url) 
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $securePassword) 
$clientContext.Credentials = $credentials 

if (!$clientContext.ServerObjectIsNull.Value) 
{ 
    Write-Host "Connected to SharePoint Online site: '$Url'" -ForegroundColor Green 
} 
$web = $clientContext.Web 
$templates = $clientContext.Site.GetCustomListTemplates($web) 
$clientContext.Load($templates) 
$clientContext.ExecuteQuery() 

$template = $templates | Where-Object{ $_.Name -eq "SomeTemplate" } 

$lci = New-Object Microsoft.SharePoint.Client.ListCreationInformation 
$lci.Title = "Some List" 
$lci.TemplateFeatureId = $template.FeatureId 
$lci.TemplateType = $template.ListTemplateTypeKind 
$lci.DocumentTemplateType = $template.ListTemplateTypeKind 

$lists = $clientContext.Web.Lists; 
$clientContext.Load($lists); 
$clientContext.ExecuteQuery(); 

$list = $lists.Add($lci) 
$list.Update() 
$clientContext.ExecuteQuery() 

私には分からないことが分かりません。何か助けていただければ幸いです。

答えて

0

フィールドをコンテンツタイプ(CT)に関連付けてから、このCTをリストに追加する必要があると思います。

はこれを見て試してみてください。

http://www.sharepointfire.com/2016/01/create-new-content-type-sharepoint-online-powershell/

前のステップでは、彼は彼が作成で使用される列(フィールド)作成: $列= "BlogNumber"、 "BlogText"、 "BlogUser"

お手伝いしますように。 アレックス

+1

また、このようなSPオンライン操作のための非常に有用な記事と主なモジュール: https://gallery.technet.microsoft.com/SharePoint-Module-for-5ecbbcf0#content –

関連する問題