Forum Discussion
Create SharePoint Online site based on .wsp template file via PowerShell
Hi Matti Paukkonen,
Thanks for the quick response! I had a go with your script and got it working. I first had a "forbidden" error when trying the Apply-PnPProvisioningTemplate, but I figured out that you had to be an administrator of the site in order to run the cmdlet (even though I was logging in with my admin account) so I worked past that.
However, what I noticed is that the images used for the landing page icons, list items created and a site page I created for the template were not taken along.
As you can see below - this is the original template site:
After running the cmdlets in PnP PowerShell I got the following:
Is there any way to get an exact copy of the original (with pictures, list items en site pages included) via PnP or any other way?
Thanks for the help so far!
Kind regards,
Sylvester
Hi Sylvester-
Images from pages can be included by adding -PersistBrandingFiles handle to Get-PnPProvisioningTemplate. And all client-side pages can be included with -IncludeAllClientSidePages handle. For example:
Get-PnPProvisioningTemplate -Out <path to xml-file> -PersistBrandingFiles -IncludeAllClientSidePages
List items cannot be included in the template. You need to create a separate script for creating list items using Add-PnPListItem. Documentation with examples can be found here: https://docs.microsoft.com/en-us/powershell/module/sharepoint-pnp/add-pnplistitem?view=sharepoint-ps&WT.mc_id=M365-MVP-5003860
- HansA220Aug 07, 2024Copper Contributor
I've been reading your replies and want to thank you in advance.
I am using MS Projects for the Web, and I create Team Sites whenever I create a group for each project.
I have a Main Template that I want to add to my "Organization Templates" so I can apply it from Sharepoint when a new project site is created. But I need an exact replica of my Main Template, including look, pictures, the files in the documents folder, lists (without items), pages, and so on.How can I do that?
I tried adding the Template from Powersheel using a JSON file, but I only get the Theme and nothing else.- ryleybauerAug 21, 2024MCTI'm trying this right now too. I've been able to export my perfect site using the "Save as template" option from the site settings (which is only available on classic sites like the PWA), then using that WSP file as Solutions and Enterprise options from the PWA settings, you can have that template become the default for when you create any PDPs.