Using PowerShell To Find ID of Template From Your Organization

Copper Contributor

Hi all, 

 

I am trying to automate the process of applying a site template within our organization to a series of new sites we are going to be creating for a SharePoint Intranet. 

 

When I manually open the site in a browser, click settings, and click Apply a Site Template, I can clearly see our available organization templates in the "From your organization" tab, seen below: 

huntaj_0-1642172663952.png

We have one called "CofC Team Site" and one called "CofC Communication Site". These templates were implemented and added to our environment by a vendor. 

 

I am simply trying to use the Invoke-PnPSiteTemplate command from the PnP.Powershell module to invoke (apply) one of these templates (either of them; if I can get one working I'll know how to do the other) to a new site collection. 

 

What I've Tried So Far

I have tried manually applying the CofC Team Site template to a new Team site, and then using the Get-PnPWebTemplates command to save the template of that new site to an XML file, and then using Invoke-PnPSiteTemplate -Path <that XML file> -Connection <connection to another site to which the template has not been applied yet>. However, that gives this error: 

Invoke-PnPSiteTemplate : Object reference not set to an instance of an object. · Issue #164 · pnp/pn...

which no one has solved. 

 

So, another available argument to the Invoke-PnPSiteTemplate is the template ID. Does anyone know how to get the IDs of the templates in the "From your organization" tab (in the screenshot above)?

0 Replies