Forum Discussion
Can we add the same templates on multiple document libraries
- 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
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
- john johnSep 21, 2023Iron Contributor
SvenSieverding thanks a lot for your reply, i tested this on my test site and it worked well,, but before applying this to PROD , will this cause any drawbacks to the document libraries? since they will reference others libraries templates? do you have any documentations about those commands as i could not find any