Retrieve SharePoint online List Templates using PowerShell

List Templates in SPO

in this article I would like to discuss about artifacts Lists and Libraries. As we know that we have some variation between SharePoint on premise and SharePoint Online, it is always good to know what available list of templates in SharePoint Online are?
For ease of access, I have implemented the below PowerShell script which will display list of available templates in SharePoint Online. You can write and debug the PowerShell script in Windows PowerShell ISE or you can also write in Visual Studio code.



function get-SPOListTemplates
{
    #Variables that needs to be set before starting the script
    $strSiteURL = “<< Site URL >>”
    $strUsrName = “<< User Name >>”
    # Reading password for the user account
    $strPWD = Read-Host “Please enter the password for $($strUsrName)” -AsSecureString
    # set SharePoint Online credentials
    $SPOCredentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($strUsrName, $strPWD)
    # Creating client context for the provided user name and password
    $objContext = New-Object Microsoft.SharePoint.Client.ClientContext($strSiteURL)
    $objContext.credentials = $SPOCredentials
    $LstTempColl = $objContext.web.listtemplates
    $objContext.load($LstTempColl)
    #Sending the request to pull all the list templates
    try{
        $objContext.executeQuery()
        write-host “The list of templates available in SPO:” -foregroundcolor white -backgroundcolor red
    }
    catch{
        write-host “info: $($_.Exception.Message)” -foregroundcolor red
    }
    #List templates available in SPO
    #$LstTempColl | select baseType, Description, ListTemplateTypeKind | ft -wrap # This will show the full description of the list template description
    $LstTempColl | select baseType, Description, ListTemplateTypeKind
}
get-SPOListTemplates
The output is as follows:
List Templates in SPO
List Templates in SPO

Now that we know list templates we can create list / library seamlessly!!! Hope this helps!!!

Similar SharePoint 2013 Tutorials


Leave a Reply