0

We are dealing with SharePoint OnPrem / 2016 in this scenario.

I have a library template located in Site Collection 1, and need to create a library in site collection 2 using this centrally located .pst file in Site Collection 1.

Every example I’ve seen so far has the .pst in the same site collection, but our scenario the .pst will stay in site collection 1 so there’s one source of truth.

Is this an option? Does the .pst have to be in the same site collection where the new library is created if using PnP?

Connect-PnPOnline -Url https://OurSiteORIG -CurrentCredentials
Get-PnPFile -Url /_catalogs/lt/TempLibrary_100Rows.stp -Path c:\temp -FileName TempLibrary_100Rows.stp -AsFile -Force

#Now the .stp file is downloaded, upload it to destination and create library
    Connect-PnPOnline -Url https://OurSiteDest -CurrentCredentials
    Add-PnPFile -Path c:\temp\TempLibrary_100Rows.stp -Folder "_catalogs/lt"
    New-PnPList -Title "MyNewLibrary" -Template TempLibrary_100Rows -OnQuickLaunch

Please advise of any example where I could accomplish this, as I'm getting the following error:

New-PnPList : Cannot bind parameter 'Template'. Cannot convert value "TempLibrary_100Rows" to type "Microsoft.SharePoint.Client.ListTemplateType". Error: "Unable to match the identifier name TempLibrary_100Rows to a valid enumerator name. Specify one of the following enumerator names and try again:

0

If you want to create a library in the site collection 2 based on the library template file in the site collection 1, you must need to upload the library template file into the list templates gallery of site collection 2.

Here’re some references about how to create list from custom list template by PowerShell.

Create SharePoint list from list template using PowerShell

How to upload custom list template and create list instance from custom list template using PowerShell in SharePoint 2013

| improve this answer | |
  • Tried using either of these examples, and they're failing. What about just a simple copy library from site collection 1 to site collection 2...that'll work for the immediate need. – Sol Web Solutions Aug 26 at 17:04
  • Scripts with Add-PSSnapin Microsoft.SharePoint.PowerShell ...do I have to run those from a machine with SharePoint Server? I'm running all this from my laptop, which won't have SharePoint server installed on it. I have no snapins registered ...returns nothing when I run >> get-pssnapin –registered – Sol Web Solutions Aug 26 at 17:22
  • Use Save document library as template is the most simple way. Here’re steps: In the site collection 1 1.Go to Library Settings -> Save document library as template -> Check Include Content checkbox. 2.Go to Site Settings -> List templates under Web Designer Galleries -> Download a copy of template file. In the site collection 2 1.Go to site settings -> List templates under Web Designer Galleries -> Upload the template file. 2.Site content -> Add an app -> Choose the template. – Emily Du - MSFT Aug 27 at 9:51
  • Our goal is to be able to run a script via PowerShell. We know how to do all these steps manually. This portion is just 1 steps of 5 total we need the script to do. – Sol Web Solutions Aug 27 at 13:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.