SharePoint 解决方案:如何获取所有List Template?
51CTO 博客地址:https://blog.51cto.com/13969817
博客园博客地址:https://www.cnblogs.com/bxapollo
由于某种原因,用户或者Division Admin需要获取当前SharePoint Online网站的List Template情况,来确定是否有Customization,是否可以做数据搬迁或者了解用户的使用情况等等,那么作为SharePoint Online Admin该如何来抓取这部分数据呢?
今天给大家分享一下,如何用脚本获取某个特定的Site Collection下的List Template以及相关描述。
执行脚本分以下2个步骤:
- 加载SharePoint Online Assemblies
- 自定义函数从给定的站点URL获取所有的列表模板
加载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"
但由于我环境的.net是4.0的,默认的情况下,禁用从远程位置加载的程序集中执行代码的功能,所以需要使用 [System.Reflection.Assembly]::LoadFrom()来加载Microsoft.SharePoint.Client.dll",如下所示:
说明:加载这两个dll文件,需要在部署SharePoint Server端执行,否则默认情况下物理路径是没有该文件的。
自定义函数从给定的站点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
在弹出的页面,输入Office 365 Global Admin的账户和密码,之后就会加载出Demo 网站的List Template以及对应的描述了,如下所示:
为了帮助大家查看,也可以直接从下表中获取相关信息:
这样我们就能获取到所有的List Template的情况了,包含customization template,希望本文对大家有所帮助,谢谢阅读。
更多相关文章
- SharePoint 排错: SharePoint Online Assemblies 加载异常
- 微服务权限终极解决方案,Spring Cloud Gateway + Oauth2 实现统一
- 详解Node模块加载机制
- 5 图看懂 Node 模块加载原理
- MyBatis 延迟加载、一二级缓存、架构设计的面试题(常问,重点了解)
- SharePoint 解决方案:如何获取Library或者List下的Item数量
- jvm系列(3)类加载机制