SharePoint Online: Tạo Thư viện Tài liệu hoặc Danh sách với Giao diện Người dùng Trải nghiệm Hiện đại bằng PowerShell
Trải nghiệm thư viện và danh sách mới trong SharePoint Online cải thiện trải nghiệm người dùng bằng cách cung cấp nhiều tính năng như điều hướng, phản hồi nhanh, giao diện người dùng di động, dễ sử dụng hơn, v.v. Bạn có thể chuyển đổi giữa trải nghiệm cổ điển và trải nghiệm mới bất kỳ lúc nào. Đây là tập lệnh PowerShell-CSOM để tạo thư viện tài liệu trong SharePoint Online với giao diện người dùng trải nghiệm mới.
Tập lệnh PowerShell để tạo thư viện tài liệu trong giao diện người dùng trải nghiệm mới:
Bạn đang tìm cách tạo thư viện tài liệu với trải nghiệm mới trong SharePoint Online? Nếu vậy, PowerShell có thể giúp bạn hoàn thành công việc.
#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"
##Variables for Processing
$SiteUrl = "https://crescent.sharepoint.com/Projects"
$UserName="salaudeen@crescent.com"
$Password ="Password goes here"
#Setup Credentials to connect
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName,(ConvertTo-SecureString $Password -AsPlainText -Force))
Try {
#Set up the context
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl)
$Context.Credentials = $credentials
#Create new document library
$ListInfo = New-Object Microsoft.SharePoint.Client.ListCreationInformation
$ListInfo.Title = "Project Documents"
$ListInfo.TemplateType = 101 #Document Library
$List = $Context.Web.Lists.Add($ListInfo)
#Set "New Experience" as list property
$List.ListExperienceOptions = "NewExperience" #Or ClassicExperience
$List.Update()
$Context.ExecuteQuery()
Write-host "New Document Library Created!" -ForegroundColor Green
}
catch {
write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}
Điều này tạo ra một thư viện mới, “Tài liệu dự án” trong giao diện người dùng trải nghiệm mới hiện đại.
PnP PowerShell để tạo danh sách hoặc thư viện tài liệu với trải nghiệm mới
Sử dụng PnP PowerShell này để tạo thư viện tài liệu với trải nghiệm mới trong SharePoint Online:
#Parameters
$SiteURL = "https://crescent.sharepoint.com/sites/Projects"
$ListName = "Team Projects"
$ListTemplate ="DocumentLibrary"
Try {
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive
#Create a document library using pnp powershell
$List = New-PnPList -Title $ListName -Template $ListTemplate -ErrorAction Stop
#Set list experience
Set-PnPList -Identity $List -ListExperience NewExperience
Write-host "List '$ListName' Created Successfully!" -f Green
}
catch {
write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}
Sử dụng “GenericList” làm $ListTemplate để tạo danh sách tùy chỉnh mới trong SharePoint Online.
