none
creazione document library da template RRS feed

  • Domanda

  • hi guys,

    i need to create lot of document library starting from a template

    i have this script that works BUT creates the Document library in my root web:


    https://****.sharepoint.com/sites/new dl

    i need to create in my subsite

    https://****.sharepoint.com/sites/****/***/DFPV/

    anyone can help me ?

    ----

    $ListTemplateInternalName="templateDF.stp"
    $ListName ="new dl"
    Connect-PnPOnline -Url https://****.sharepoint.com/sites/****/***/DFPV/ -Credential (Get-credential)

    $Context = Get-PnPContext
    $Web = $Context.Site.RootWeb
    $ListTemplates = $Context.Site.GetCustomListTemplates($Web)
    $Context.Load($Web)
    $Context.Load($ListTemplates)
    Invoke-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)
    Invoke-PnPQuery

    Disconnect-PnPOnline
    ----

    venerdì 4 gennaio 2019 16:46