Forum Discussion

john john's avatar
john john
Iron Contributor
Sep 20, 2023
Solved

Can we add the same templates on multiple document libraries

I have created a PDF template named Shipping, inside a document library inside our SharePoint online, as follow:-       now i need to share this template with 20 document libraries, is ther...
  • SvenSieverding's avatar
    Sep 21, 2023

    Hi john john ,

    you can automate that if you use PnP Powershell.

    First modify the "New" menu of one document library like you want them all to look. Then execute these Powershell commands

    # Get the template
    Connect-PnPOnline https://<tenant>.sharepoint.com/sites/<site> -UseWebLogin
    $listname="Name of the base document library"
    $view = Get-PnpView -List $listname | Where-Object {$_.DefaultView -eq $true}
    $template=$view.NewDocumentTemplates


    This will load the configuration of the "New" menu inside of the variable "$template". Keep the PowerShell window open and enter these lines

    # If the library is on a different site than the other library
    #Connect-PnPOnline https://<tenant>.sharepoint.com/sites/<site> -UseWebLogin
    
    $listname="Name of the documentlibrary you want to apply the template to"
    $view = Get-PnpView -List $listname | Where-Object {$_.DefaultView -eq $true}
    $view.NewDocumentTemplates = $template
    $view.Update()
    Invoke-PnPQuery	

     That will apply the same "New" Menu to that other document library. It will not upload the document templates a second time but will configure both libraries to use the same template file.

    Best Regards,
    Sven

Resources