SharePoint solution: How to get all List Templates?

51CTO blog address: https://blog.51cto.com/13969817blog
garden blog address: https://www.cnblogs.com/bxapollo

For some reason, the user or Division Admin needs to obtain the List Template status of the current SharePoint Online website to determine whether there is Customization, whether it can do data relocation or understand the user's usage, etc., then how to grab it as a SharePoint Online Admin What about this part of the data?

Today I will share with you how to use a script to get the List Template and related descriptions of a specific Site Collection .

The execution script is divided into the following 2 steps:

  • Load SharePoint Online Assemblies
  • Custom function to get all list templates from the given site URL

Command to load SharePoint Online Assemblies:

  • Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
  • Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

But because the .net of my environment is 4.0, by default, the function of executing code in assemblies loaded from remote locations is disabled, so you need to use [System.Reflection.Assembly]::LoadFrom() to load Microsoft.SharePoint .Client.dll" as shown below:

SharePoint solution: How to get all List Templates?

Note: To load these two dll files, you need to execute it on the SharePoint Server deployment side, otherwise the physical path does not have the file by default.

Custom function to get all list templates from the given site URL

$SiteURL="https://mvptrainingcn.sharepoint.com/sites/Demo2"
    #Get Credentials to connect
    $Cred= Get-Credential
    $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)

    #Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = $Credentials

    #Get All list templates
    $ListTemplates=$Ctx.Web.ListTemplates
    $Ctx.Load($ListTemplates)
    $Ctx.ExecuteQuery()

    #Get All Available list templates
        $ListTemplates | Select Name, Description, ListTemplateTypeKind| Sort-Object Name | Format-Table -AutoSize

SharePoint solution: How to get all List Templates?

On the pop-up page, enter the account and password of the Office 365 Global Admin, and then the List Template of the Demo website and the corresponding description will be loaded, as shown below:

SharePoint solution: How to get all List Templates?

In order to help you check, you can also directly obtain relevant information from the following table:

SharePoint solution: How to get all List Templates?
SharePoint solution: How to get all List Templates?

In this way, we can get all the List Template information, including the customization template. I hope this article is helpful to everyone. Thank you for reading.

Guess you like

Origin blog.51cto.com/13969817/2590482