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,但願本文對你們有所幫助,謝謝閱讀。

相關文章
相關標籤/搜索