By Softlanding

Remotely provision a list using CustomSchemaXml

September 29, 2017

This PowerShell script will provi​sion a new list remotely using ListCreationInformation.CustomSchemaXml.

Further below is an example of the XML to be fed in, which is the tricky part.​


    [Parameter(Mandatory = $true)][string]$webUrl,

    [Parameter(Mandatory = $true)][string]$schemaXmlFilePath,

    [Parameter(Mandatory = $true)][int]$listTemplateId



$csom = [Reflection.Assembly]::LoadWithPartialName('Microsoft.SharePoint.Client')

$ctx = New-Object Microsoft.SharePoint.Client.ClientContext $webUrl





$schemaXml = [xml] (Get-Content $schemaXmlFilePath)

$template = $ctx.Web.ListTemplates | WHERE { $_.ListTemplateTypeKind -eq $listTemplateId }

$info = New-Object Microsoft.SharePoint.Client.ListCreationInformation

$info.Title = $schemaXml.List.Title

$info.Url = $schemaXml.List.Url

$info.CustomSchemaXml = $schemaXml.OuterXml

$info.TemplateType = $listTemplateId

$info.TemplateFeatureId = $template.FeatureId


$list = $ctx.Web.Lists.Add($info)


This script works against SharePoint 2010 and SharePoint 2013, but requires PowerShell v3 or higher.

​How to structure the XML

Simply grabbing the SchemaXml from an existing list does not work. 

An easy way to start is to use Visual Studio. Add a list to a SharePoint project and then grab the Schema.xml file. It can be used as-is. Here is an example generated when choosing the Custom List template.">








  " StaticName="Title" MaxLength="255" />

















































Loading Conversation