Get All Web Templates Using PowerShell SharePoint 2013

This script will traverse all the site collections and extract its template name.

1.Site Collections File

Create text file with name “SiteCollections.txt” in the same directory where script file is present.
Write site collections urls in “SiteCollections” file. 
Make it sure each url should be in new line and write “End Point” at the end as shown below.


2. Save Code and Run
Save below code and Open SharePoint Management Shell. Change the directory to where the code and SiteCollections.txt file is saved and run the code script file.

The output would be like below.


PS Script:

$currentTime = Get-Date -Format o | foreach {$_ -replace ":", "."}
New-Item $PSScriptRoot\GetAllWebTemplates-$currentTime.txt -type file
$SiteCollectionArray =  Get-Content -Path $PSScriptRoot\SiteCollections.txt


 Start-Transcript -Path "$PSScriptRoot\GetAllWebTemplates-$currentTime.txt"
  $UtilStartTime = "Utility Start Time: "
  $startTime = Get-Date  -Format F
  $UtilStartTime +  $startTime

 foreach ($url in $SiteCollectionArray)
 {

 if($url -ne "End Point") 
    {
     
    try{
    $site=Get-SPSite -Identity $url
    }
    catch
    {}

        foreach($web in $site.AllWebs)
        {
            if($web)
              {
                     $output = $site.URL +  "`t"  + $web.URL +  "`t"  + $web.WebTemplate +  "`t"  + $web.WebTemplateId
                     Write-Output $output
                     $web.Dispose()
            }

            else
              {
              Write-Output "Site Doesn't exist"
            }
         }

    }
 }

$UtilEndTime = "Utility End Time: "
$endTime = Get-Date  -Format F
$UtilEndTime +  $endTime
Stop-Transcript


Comments

Popular Posts

GREYCstoration Oil Paint plugin for Photoshop

Service Bus Gateway service stuck at Starting

PowerApps SubmitForm not clearing People Picker value

Apple iPhone sending SMS automatically 00447786205094

Download file failed signature verification and may have been tampered with - Workflow Manger 1.0 Refresh (CU2)