EnjoySharePoint YouTube Channel

How to retrieve all site templates available in SharePoint Online using PowerShell?

Site collection templates in SPO

In this SharePoint Online tutorial, we will discuss how to retrieve all site templates available in SharePoint Online using PowerShell. We will retrieve site template id and site template name in SharePoint Online using PowerShell.

Get Office 365 Enterprise E3 Or Business Premium Subscription & Try out all the features

We all know that these days Microsoft is more focused on expanding SharePoint online scope and abilities widely. Let me share some of my knowledge to add an extra feather in your crown. To start up with SPO we need to know what are the various site collection templates available for us.


If you are new to PowerShell SharePoint then read Working with PowerShell in SharePoint Online/2016/2013.

What is required?

In SharePoint on-premise environment we will have more than 100 templates which support both SharePoint 2010 and 2013 with the compatibility modes as 14 & 15, but in SharePoint Online we will max 16 templates.

PowerShell Script to retrieve all site templates available in SharePoint Online

With the below script you can see all the available web templates in SharePoint Online Office 365.

try {
function get-SPOnlineWebTemplates {
#SharePOint Online Admin Site URL
$adminUrl = “<<Sharepoint SPO Admin site URL>>”
#SharePoint Online Admin ID
$userName = “<<SharePoint SPO admin account>>”
#reading password from command prompt
$password = Read-Host “Please the Password for Admin account” -AsSecureString
#set credentials for SharePoint Online
$credentials = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $userName, $password
#connect to SharePoint Online
Connect-SPOService -Url $adminUrl -Credential $credentials
#Fetching all the Site template Names
get-spoWebTemplate | select @{N = ‘Template ID’; E = {$_.Name}}, @{N = ‘Template Name’; E = {$_.Title}}, @{N = ‘Compatibility Level’; E = {$_.CompatibilityLevel}}
}
get-SPOnlineWebTemplates
}
catch {
Write-Host “`nError:: $($_.Exception.Message)” -foregroundcolor red -BackgroundColor Yellow
}

In the above script I am changing column name with alias as follows:

select @{N = ‘Template ID’; E = {$_.Name}}

In this statement Template ID is alias name and the actual column name is Name.

The output with the list of site template is as follows:

Site collection templates in SPO
Site collection templates in SPO

In the next article, we will learn how to create Site Collection in SharePoint Online using PowerShell.

You may like following SharePoint PowerShell tutorials:

Happy development in SharePoint Online and hope this SharePoint online tutorial helps to retrieve all site templates available in SharePoint Online using PowerShell.

Check out Best Alternative to InfoPath -> Try Now
You May Also like the Following SharePoint Tutorials:

About Krishna Vandanapu

I am Krishna.Vandanapu a SharePoint architect working in IT from last 13+ years, I worked in SharePoint 2007, 2010, 2013, 2016 and Office 365. I have extensive hands on experience in customizing SharePoint sites from end to end. Expertise in SharePoint migration tools like Sharegate, Doc Ave and Metalogix. Migrated SharePoint sites from SharePoint 2007 to 2010 and 2010 to 2013 several times seamlessly. Implementing CSOM with Microsoft best practices. Spent quality time in configuring SharePoint application services like User Profile, Search, Managed Meta data services etc. Now exploring SharePoint Framework and SharePoint 2019

View all posts by Krishna Vandanapu →