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

Site collection templates in SPO
InfoPath alternatives for form designing SharePoint

Objective:
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 you crown. To start up with SPO we need to know what are the various site collection templates available for us.

In this article I would like to walk you through how we can create site collection in SharePoint Online using PowerShell.

What is required?
– Basics in PowerShell scripting
– SharePoint Online Management Shell (if you don’t have it you can download from below link) https://www.microsoft.com/en-us/download/details.aspx?id=35588
– SharePoint Online Admin account

Read SharePoint 2013 tutorials

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

With the below script you can see all the available web templates in SharePoint Online:



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.

Happy development in SharePoint Online. !!!!

Similar SharePoint 2013 Tutorials

About Krishna Vandanapu

I am Krishna.Vandanapu a SharePoint architect working in IT from last 12 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 →

Leave a Reply