SharePoint 解决方案:如何获取全部List Template?

51CTO博客地址:https://blog.51cto.com/1396817函数

博客园博客地址:https://www.cnblogs.com/bxapollo网站

因为某种缘由,用户或者Division Admin须要获取当前SharePoint Online网站的List Template状况,来肯定是否有Customization,是否能够作数据搬迁或者了解用户的使用状况等等,那么做为SharePoint Online Admin该如何来抓取这部分数据呢?.net

今天给你们分享一下,如何用脚本获取某个特定的Site Collection下的List Template以及相关描述。3d

执行脚本分如下2个步骤:orm

  1. 加载 SharePoint Online Assemblies
  2. 自定义函数从给定的站点 URL 获取全部的列表模板

加载 SharePoint Online Assemblies 的命令:blog

•	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"

但因为我环境的.net是 4.0,默认的状况下,禁用从远程位置加载的程序集中执行代码的能力,因此须要使用[System.Reflection.Assembly]::LoadFrom()来加载Microsoft.SharePoint.Client.dll,以下所示:ip

 

说明:加载这两个dll文件,须要在部署SharePoint Server端执行,不然默认的状况下物理路径是没有该文件的。部署

自定义函数从给定的站点URL获取全部的列表模板get

$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

在弹出的页面,输入Office 365 Global Admin的帐户和密码,以后就会加载Demo网站的List template以及对应的描述了,以下所示:博客

 

 为了帮助 你们查看,也能够直接从下表中获取相关信息:

 

 

 

 这样,咱们就获取到全部的list template的状况下,包含Customization Template,但愿本文对你们有所帮助,谢谢阅读。

相关文章
相关标签/搜索