Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#region Configuration
$Url = "https://TENANTID.sharepoint.com" # URL of the site
$ListTemplateInternalName = "CorpMenu.stp" # Change this with your own list template
$ListName = "Menu" # Change this with the name of the list to be created
#endregion
#region Create list from template
Connect-PnPOnline -Url $Url
$Context = Get-PnPContext
$Web = $Context.Site.RootWeb
$ListTemplates = $Context.Site.GetCustomListTemplates($Web)
$Context.Load($Web)
$Context.Load($ListTemplates)
Execute-PnPQuery
$ListTemplate = $ListTemplates | where { $_.InternalName -eq $ListTemplateInternalName }
if ($ListTemplate -eq $null)
{
Throw [System.Exception] "Template not found"
}
$ListCreation = New-Object Microsoft.SharePoint.Client.ListCreationInformation
$ListCreation.Title = $ListName
$ListCreation.ListTemplate = $ListTemplate
$Web.Lists.Add($ListCreation)
Execute-PnPQuery
Disconnect-PnPOnline
#endregion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.