Find All Site Templates Used by SharePoint Sites
Requirement: Find all Site templates used in a SharePoint 2010 environment and generate a report before proceeding with Migration, as certain templates are discontinued in SharePoint 2013.
Solution: let’s get a site template usage report on all sites using PowerShell.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Variables
$WebAppURL="https://sp10.crescent.com"
#Get All Webs
$WebsCollection = Get-SPWebApplication $WebAppURL | Get-SPSite -Limit All | Get-SPWeb -Limit All
#Retrieve Site template data from each web
foreach ($web in $WebsCollection)
{
$SiteName = $web.Title
$SiteURL = $web.Url
$SiteTemplate = $web.WebTemplate
$TemplateID = $web.WebTemplateID
Write-Host " $($SiteName), $($SiteURL), $($SiteTemplate) ,$($TemplateID)"
}
PowerShell Script to Get Web Templates of all sites and Export to CSV Report:
Let’s tweak it a bit to find all site templates and export them to a CSV file.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Variables
$WebAppURL="https://portal.crescent.com"
$ReportFile="C:\Reports\WebTemplates.csv"
#Get All Webs
$WebsCollection = Get-SPWebApplication $WebAppURL | Get-SPSite -Limit All | Get-SPWeb -Limit All
#Array to Hold Result - PSObjects
$ResultCollection = @()
#Retrieve Site template data from each web
foreach ($web in $WebsCollection)
{
$Result = New-Object PSObject
$Result | Add-Member NoteProperty SiteName($web.Title)
$Result | Add-Member NoteProperty SiteURL($web.URL)
$Result | Add-Member NoteProperty SiteTemplate($web.WebTemplate)
$Result | Add-Member NoteProperty WebTemplateID($web.WebTemplateID)
#Add the object with property to an Array
$ResultCollection += $Result
}
Write-host "Web Templates Report Generated Successfully!" -f Green
#Export the result Array to CSV file
$ResultCollection | Export-CSV $ReportFile -NoTypeInformation
To find a site template being used by a particular site, Refer to How to find the site template in SharePoint?