51CTO博客地址:https://blog.51cto.com/1396817
博客園博客地址: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,希望本文對大家有所幫助,謝謝閱讀,
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/248911.html
標籤:其他
上一篇:操作工技能培訓系統
下一篇:Dockerfile構建鏡像
