List Site Templates and IDs in SharePoint 2010 Using Windows PowerShell

One of the main checkpoints you will have to worry about as you upgrade or migrate SharePoint sites across farms or versions are custom site templates and how they are handled during migrations. You may upgrade or migrate custom site templates as is or you may elect to re-template site templates. A perfect place to start would be to know what custom site templates you have. So I did some research and finally stumbled upon a couple of scripts that I want to share with you. These scripts will help you:

  • List all site collections within a web application <– This will give us a better understanding of the total number of sites we may consider for migrations
Get-SPWebApplication “http://WebAppAddress“| Get-SPSite -limit ALL|Get-SPWeb -limit ALL|Select-Object Title,Url
  • List all site templates and template IDs for a given web application <– So we end up knowing what is standard and what is custom
$webapp = Get-SPWebApplication -identity http://WebAppAddress/
$webtem = Get-spwebtemplate
foreach ($site in $webapp.Sites)
 $spweb = get-spweb $site.URL
 write-host “Site URL: ” $site.URL
 write-host “Web Template: ” $spweb.WebTemplate
 write-host “WebTemplateID: ” $spweb.WebTemplateID
 write-host “————————————-”
  • List site template and site ID for a given site <– If there is a specific site we want to migrate and are interested in knowing what template it was created from
$web = Get-SPWeb http://webapp/sites/site/subsiteaddress
write-host “Web Template:” $web.WebTemplate ” | Web Template ID:” $web.WebTemplateId
  • In general a list of all site templates available <– If you just want to see what site templates you have
 Get-SPWebTemplate | Sort-Object “Name”

I’ve recorded a short video to demonstrate the above.

Video length: 3:56

Ghazwan Khairi

SharePoint Quester

Leave a Comment