SharePoint Online: Đặt cấu hình cài đặt danh sách bằng PowerShell
Yêu cầu: Chỉnh sửa cài đặt danh sách trong SharePoint Online bằng PowerShell.
Làm cách nào để thay đổi cài đặt danh sách trong SharePoint Online?
Thiết đặt danh sách trong SharePoint Online xác định các thuộc tính của danh sách, chẳng hạn như Tên, mô tả, v.v. và chức năng của danh sách. Những cài đặt này có thể được định cấu hình bằng cách điều hướng đến trang cài đặt danh sách. Bài đăng blog này sẽ hướng dẫn các bước cần thiết để định cấu hình cài đặt danh sách.
Để quản lý các cài đặt này, hãy làm như sau:
Điều hướng đến trang Cài đặt danh sách hoặc thư viện từ Cài đặt >> Cài đặt danh sách. Tất cả các cài đặt của danh sách hoặc thư viện đều nằm trên một trang này. Từ trang này, Bạn có thể định cấu hình các tùy chọn Tên danh sách, Mô tả và Điều hướng. Tương tự, phiên bản, bảo mật, v.v.
SharePoint Online: PowerShell để đặt cài đặt danh sách
Việc cập nhật thuộc tính cho thư viện tài liệu trong SharePoint Online có thể được thực hiện thủ công nhưng nếu có nhiều thư viện cần được cập nhật thì việc này có thể khá tốn thời gian. Tập lệnh PowerShell có thể được viết để tự động hóa quá trình này và làm cho quá trình này nhanh hơn và dễ dàng hơn. Đây là PowerShell để cập nhật các thuộc tính phổ biến nhất của danh sách hoặc thư viện SharePoint Online:
#Load SharePoint CSOM 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"
#Set Config Parameters
$SiteURL="https://crescent.sharepoint.com/"
$ListName="Projects"
#Get Credentials to connect
$Cred= Get-Credential
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
#Get the List
$List=$Ctx.Web.Lists.GetByTitle($ListName)
#Allow management of content types?
$List.ContentTypesEnabled=$True
#Make "New Folder" command available?
$List.EnableFolderCreation=$True
#Enable Attachments: Applicable Only for Lists!
$List.EnableAttachments=$True
#Require content approval for submitted items?
$List.EnableModeration=$True
#Require documents to be checked out before they can be edited: Applicable Only for Libraries!
$List.ForceCheckout=$True
#Display this list using the new or classic experience?
$List.ListExperienceOptions = "NewExperience" #ClassicExperience or Auto
#Draft Item Security
$List.DraftVersionVisibility = [Microsoft.SharePoint.Client.DraftVisibilityType]::Approver #Reader, Approver, Author
#Quick Edit - Allow items in this document library to be edited using Quick Edit and the Details Pane?
$List.DisableGridEditing=$true
#Offline Client Availability
$List.ExcludeFromOfflineClient = $True
#Apply the settings to list
$List.Update()
$Ctx.ExecuteQuery()
Write-host -f Green "List Settings Updated!"
Bạn cũng có thể sử dụng tập lệnh PowerShell này để cập nhật thuộc tính thư viện tài liệu trong SharePoint Online.
PnP PowerShell để cập nhật thuộc tính thư viện tài liệu trong SharePoint Online
Để cập nhật cài đặt danh sách hoặc thư viện tài liệu, chúng ta có thể sử dụng các tập lệnh PnP PowerShell này bằng lệnh ghép ngắn Set-PnPList.
#Config Variables
$SiteURL = "https://Crescent.sharepoint.com"
$ListName ="Projects"
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive
#Get the List
$List = Get-PnPList -Identity $ListName
#powershell script to update document library properties in sharepoint online
If($List)
{
#Enable versioning and set Number of versions to 50
Set-PnPList -Identity $List -EnableVersioning $True -MajorVersions 50
#Enable Content Type Management
Set-PnPList -Identity $List -EnableContentTypes $True
#Content Approval
Set-PnPList -Identity $List -EnableModeration $True
#Enable Folders
Set-PnPList -Identity $List -EnableFolderCreation $True
#Enable Attachments
Set-PnPList -Identity $List -EnableAttachments $True
#Require Checkout
Set-PnPList -Identity $List -ForceCheckout $True
#Set List Experience
Set-PnPList -Identity $List -ListExperience NewExperience
}
Cũng có thể kết hợp các hoạt động này trong một dòng duy nhất. Ví dụ.,
Set-PnPList -Identity $List -EnableAttachments $True -EnableContentTypes $True -EnableFolderCreation $True
Xin lưu ý, PnP PowerShell không cung cấp tham số cho tất cả thuộc tính có sẵn của danh sách hoặc thư viện tài liệu SharePoint Online. Vì vậy, bạn có thể sử dụng như sau:
#Config Variables
$SiteURL = "https://crescent.sharepoint.com"
$ListName ="Project Config"
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive
#Get the List
$List = Get-PnPList -Identity $ListName
#Set List Property
$List.Hidden = $True
$List.Update()
Invoke-PnPQuery
Các bài đăng khác của tôi về cách định cấu hình cài đặt Danh sách trong SharePoint Online bằng PowerShell:
- SharePoint Online: Định cấu hình Danh sách và Thư viện Phiên bản bằng PowerShell
- SharePoint Online: Xóa danh sách khỏi tìm kiếm bằng cách đặt thuộc tính NoCrawl bằng PowerShell
- SharePoint Online: Đặt Tiêu đề Danh sách, Mô tả và Tùy chọn dẫn hướng khởi chạy nhanh bằng PowerShell
Đây là một bài viết khác để nhận Cài đặt danh sách SharePoint Online: SharePoint Online: PowerShell để lấy cài đặt danh sách
