{"id":3511,"date":"2012-04-01T13:21:56","date_gmt":"2012-04-01T21:21:56","guid":{"rendered":"https:\/\/www.zubairalexander.com\/stage\/?p=3511"},"modified":"2019-09-08T18:15:25","modified_gmt":"2019-09-09T01:15:25","slug":"powershell-script-to-find-site-template-id","status":"publish","type":"post","link":"https:\/\/www.zubairalexander.com\/blog\/powershell-script-to-find-site-template-id\/","title":{"rendered":"PowerShell Script to Find Site Template ID"},"content":{"rendered":"<p>I often create a new site collection based on Microsoft Office SharePoint Server (MOSS) 2007 Collaboration Portal template for my clients&#8217; intranet site. Just so you know, the Collaboration Portal template is hidden in SharePoint Server 2010. I use a PowerShell script to create the top-level site collection using the site template ID (SPSPORTAL#0) for the Collaboration Portal, as documented in my post <a href=\"https:\/\/www.zubairalexander.com\/blog\/installing-collaboration-portal-template-in-sharepoint-2010\/\">Installing Collaboration Portal in SharePoint 2010<\/a>.<\/p>\n<p>Sometimes you may want to create a site based on your own custom site template that you have previously saved. Of course, if the site is a subsite then you can use the GUI to create the site, unless it&#8217;s a hidden template. However, if you want to use a script, and there are several situations where you may want to do that, the following script will come handy to create a new site based on a custom site template. Thanks to SharePoint MVP Alex Pierce for this script.<\/p>\n<p><strong>Step 1<\/strong><\/p>\n<p>Get the site template ID using the following method.<\/p>\n<ol>\n<li>Enter the following text in Notepad.<br \/>\n$url = \u201chttp:\/\/www.contoso.com\/\u201d<br \/>\n$site= new-Object Microsoft.SharePoint.SPSite($url )<br \/>\n$loc= [System.Int32]::Parse(1033)<br \/>\n$templates= $site.GetWebTemplates($loc)<br \/>\nforeach ($child in $templates){ write-host $child.Name \u201c\u00a0 \u201d $child.Title}<em>Replace &#8220;http:\/\/www.contoso.com\/&#8221; with your site URL.<\/em><\/li>\n<li>Save the file with .ps1 extension, e.g. GetSiteID.ps1.<\/li>\n<li>Run the file in PowerShell.<\/li>\n<li>You will see all the sites and their IDs displayed.<\/li>\n<li>Make a note of your custom site&#8217;s ID.<\/li>\n<\/ol>\n<p><strong>Step 2<\/strong><\/p>\n<p>Use the method documented in my post\u00a0<a href=\"https:\/\/www.zubairalexander.com\/blog\/installing-collaboration-portal-template-in-sharepoint-2010\/\">Installing Collaboration Portal in SharePoint 2010<\/a>\u00a0to create a new site based on your custom site ID.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I often create a new site collection based on Microsoft Office SharePoint Server (MOSS) 2007 Collaboration Portal template for my clients&#8217; intranet site. Just so you know, the Collaboration Portal template is hidden in SharePoint Server 2010. I use a PowerShell script to create the top-level site collection using the site template ID (SPSPORTAL#0) for [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[57,54,11],"tags":[],"class_list":["post-3511","post","type-post","status-publish","format-standard","hentry","category-scripting","category-sharepoint","category-tips-tricks"],"aioseo_notices":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.zubairalexander.com\/blog\/wp-json\/wp\/v2\/posts\/3511","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zubairalexander.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zubairalexander.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zubairalexander.com\/blog\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zubairalexander.com\/blog\/wp-json\/wp\/v2\/comments?post=3511"}],"version-history":[{"count":0,"href":"https:\/\/www.zubairalexander.com\/blog\/wp-json\/wp\/v2\/posts\/3511\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zubairalexander.com\/blog\/wp-json\/wp\/v2\/media?parent=3511"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zubairalexander.com\/blog\/wp-json\/wp\/v2\/categories?post=3511"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zubairalexander.com\/blog\/wp-json\/wp\/v2\/tags?post=3511"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}