kwizcom banner advertisement

Find All Site Templates Used by SharePoint Sites

Requirement: Find all Site templates used in a SharePoint 2010 environment and generate report prior proceeding with Migration, as certain templates are discontinued in SharePoint 2013.

Solution: Lets get site template usage report on all sites using PowerShell.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Variables
$WebAppURL="http://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:
Lets tweak it a bit to find all site templates and export to 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: How to find site template in SharePoint
Find All Site Templates Used by SharePoint Sites Find All Site Templates Used by SharePoint Sites Reviewed by Salaudeen Rajack on July 16, 2014 Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.