SharePoint Online: Thay đổi từ Trải nghiệm cổ điển sang Hiện đại (và ngược lại) bằng PowerShell
Yêu cầu: Thay đổi trang SharePoint Online từ Trải nghiệm Cổ điển sang Hiện đại.
Làm cách nào để kích hoạt trải nghiệm hiện đại từ cổ điển?
Trải nghiệm hiện đại trong danh sách và thư viện SharePoint Online nhanh hơn, thân thiện với thiết bị di động và dễ sử dụng hơn. Nó mang đến các chức năng, giao diện người dùng và các thành phần mới. Tuy nhiên, một số tính năng chỉ có thể được sử dụng trong trải nghiệm cổ điển. Vì vậy, bạn có thể cần chuyển đổi giữa giao diện người dùng hiện đại và trải nghiệm cổ điển trong SharePoint Online. Làm cách nào để thay đổi từ dạng xem cổ điển sang dạng xem hiện đại trong SharePoint? Để kích hoạt trải nghiệm thư viện hiện đại mới trong SharePoint Online, hãy sử dụng liên kết “Thoát trải nghiệm cổ điển” ở góc dưới cùng bên trái.
Điều này BẬT trải nghiệm hiện đại. Làm cách nào để hoàn nguyên về phiên bản cổ điển trong SharePoint Online? Chà, để tắt trải nghiệm hiện đại và chuyển về cổ điển trong SharePoint Online, hãy sử dụng liên kết “Trở lại SharePoint cổ điển”.
Trong trường hợp bạn không nhận được tùy chọn “Quay lại SharePoint cổ điển” hoặc “Thoát trải nghiệm cổ điển”, rất có thể tính năng này chưa được bật! Làm cách nào để bật hoặc tắt “Quay lại SharePoint cổ điển” trong SharePoint Online?
PowerShell để chuyển từ trải nghiệm cổ điển sang hiện đại
Để kích hoạt trải nghiệm hiện đại, chúng tôi phải tắt tính năng trải nghiệm cổ điển. Và để tắt trải nghiệm hiện đại, chúng ta nên kích hoạt lại tính năng trải nghiệm cổ điển trong SharePoint Online. Tập lệnh PowerShell này được chia thành hai chức năng khác nhau.
- Đặt trạng thái tính năng nhất định thành bật hoặc tắt ở phạm vi nhất định, chẳng hạn như Trang web hoặc Web.
- Kích hoạt tính năng liên quan ở (các) phạm vi thích hợp để thiết lập trải nghiệm giao diện người dùng.
Bạn có thể sử dụng tập lệnh PowerShell này để bật hoặc tắt trải nghiệm hiện đại ở cấp độ tuyển tập trang hoặc trang. Tập lệnh này đặt trải nghiệm hiện đại hoặc trải nghiệm cổ điển trên các đối tượng: Danh sách và thư viện (Nếu cài đặt trải nghiệm danh sách là: “Trải nghiệm mặc định cho trang web”), Nội dung trang web, cách sử dụng trang web, Thùng rác, v.v.
#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"
#Function to Enable or Disable Feature in SharePoint Online
Function Set-SPOFeatureStatus
{
[CMDLetBinding()]
Param
(
[Parameter(Mandatory=$True)][Microsoft.SharePoint.Client.ClientContext]$Context,
[Parameter(Mandatory=$True)][GUID]$FeatureGUID,
[Parameter(Mandatory=$True)][ValidateSet('Site','Web')][String]$Scope,
[Parameter(Mandatory=$True)][ValidateSet('Enable','Disable')][String]$Status
)
If($Scope -eq "Site")
{
#Get the Site
$Site = $Context.Site
#Get the Feature Status
$FeatureStatus = $Site.Features.GetById($FeatureGuid)
$FeatureStatus.Retrieve("DefinitionId")
$Context.Load($FeatureStatus)
$Context.ExecuteQuery()
If($Status -eq "Enable")
{
#Activate the feature if its not enabled already
If($FeatureStatus.DefinitionId -eq $null)
{
#Enable the Feature
$Site.Features.Add($FeatureGuid, $True, [Microsoft.SharePoint.Client.FeatureDefinitionScope]::None) | Out-Null
$Context.ExecuteQuery()
Write-host -f Green "`tFeature has been Enabled at Site Level!"
}
Else
{
Write-host -f Yellow "`tFeature is Already Enabled at Site Level!"
}
}
Elseif($Status -eq "Disable")
{
#De-Activate the feature if its enabled already
If($FeatureStatus.DefinitionId -ne $null)
{
#Disable feature
$Site.Features.Remove($FeatureGuid, $True) | Out-Null
$Context.ExecuteQuery()
Write-host -f Green "`tFeature has been Disabled at Site Level!"
}
Else
{
Write-host -f Yellow "`tFeature is Already Disabled at Site Level!"
}
}
}
ElseIf($Scope -eq "Web")
{
#Get the web
$Web = $Context.Web
#Get the Feature Status
$FeatureStatus = $Web.Features.GetById($FeatureGUID)
$FeatureStatus.Retrieve("DefinitionId")
$Context.Load($FeatureStatus)
$Context.ExecuteQuery()
If($Status -eq "Enable")
{
#Activate the feature if its not enabled already
If($FeatureStatus.DefinitionId -eq $null)
{
#Enable Feature
$Web.Features.Add($FeatureGUID, $True, [Microsoft.SharePoint.Client.FeatureDefinitionScope]::None)| Out-Null
$Context.ExecuteQuery()
Write-host -f Green "`tFeature has been Enabled at Web Level!"
}
Else
{
Write-host -f Yellow "`tFeature is Already Enabled at Web Level!"
}
}
ElseIf($Status -eq "Disable")
{
#De-Activate the feature if its enabled already
If($FeatureStatus.DefinitionId -ne $null)
{
#Disable Classic Experience feature, which Enables Modern UI
$Web.Features.Remove($FeatureGUID, $True) | Out-Null
$Context.ExecuteQuery()
Write-host -f Green "`tFeature has been Disabled at Web Level!"
}
Else
{
Write-host -f Yellow "`tFeature is Already Disabled at Web Level!"
}
}
}
}
#Function to set UI experience to Modern or Classic at Site or Web Level
Function Set-SPOUIExperience
{
[CMDLetBinding()]
Param
(
[String]$SiteURL,
[Parameter(Mandatory=$True)][ValidateSet('Modern','Classic')][String]$Experience,
[Parameter(Mandatory=$True)][ValidateSet('Site','Web')][String]$Scope
)
Try {
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
#Site Scoped Feature "EnableDefaultListLibrarExperience" - Classic Experience
$SiteFeatureGuid = New-Object System.Guid "E3540C7D-6BEA-403C-A224-1A12EAFEE4C4"
#Web Scoped Feature "EnableDefaultListLibrarExperience" - Classic Experience
$WebFeatureGUID = New-Object System.Guid "52E14B6F-B1BB-4969-B89B-C4FAA56745EF"
#Enable or Disable Modern Experience based on the parameters
If($Scope -eq "Site")
{
#Get the web
$Web = $Ctx.Web
$Ctx.Load($Web)
$Ctx.ExecuteQuery()
If($Experience -eq "Modern")
{
#Disable Classic Experience feature at site level
Write-host -f Green "Enabling Modern Experience at the Site Collection by Disabling Classic UI Feature..."
Set-SPOFeatureStatus -Context $Ctx -FeatureGUID $SiteFeatureGuid -Scope Site -Status Disable
#Disable Classic Experience feature at web level
Set-SPOUIExperience $Web.URL -Experience $Experience -Scope Web
#Process each subsite in the site
$Subsites = $Web.Webs
$Ctx.Load($Subsites)
$Ctx.ExecuteQuery()
Foreach ($SubSite in $Subsites)
{
#Call the function Recursively
Set-SPOUIExperience $SubSite.URL -Experience $Experience -Scope Web
}
}
ElseIf($Experience -eq "Classic")
{
#Enable Classic Experience feature at site level
Write-host -f Green "Enabling Classic Experience at the Site Collection..."
Set-SPOFeatureStatus -Context $Ctx -FeatureGUID $SiteFeatureGuid -Scope Site -Status Enable
#Enable Classic Experience feature at web level
Set-SPOUIExperience $Web.URL -Experience $Experience -Scope Web
#Process each subsite in the site
$Subsites = $Web.Webs
$Ctx.Load($Subsites)
$Ctx.ExecuteQuery()
Foreach ($SubSite in $Subsites)
{
#Call the function Recursively
Set-SPOUIExperience $SubSite.URL -Experience $Experience -Scope Web
}
}
}
ElseIf($Scope -eq "Web")
{
If($Experience -eq "Modern")
{
#Disable Classic Experience
Write-host -f Green "Enabling Modern Experience at the Web $($SiteURL) by Disabling Classic UI Feature..."
Set-SPOFeatureStatus -Context $Ctx -FeatureGUID $WebFeatureGUID -Scope Web -Status Disable
}
ElseIf($Experience -eq "Classic")
{
#Enable Classic Experience
Write-host -f Green "Enabling Classic Experience at the Web $($SiteURL)"
Set-SPOFeatureStatus -Context $Ctx -FeatureGUID $WebFeatureGUID -Scope Web -Status Enable
}
}
}
Catch {
write-host -f Red "Error:" $_.Exception.Message
}
}
#Set Variable
$SiteURL = "https://crescent.sharepoint.com/sites/marketing"
#Get Credentials to connect
$Cred = Get-Credential
#Call the function to set UI experience
Set-SPOUIExperience -SiteURL $SiteURL -Experience Modern -Scope Site
Khi bạn kích hoạt tính năng cấp trang web, các trang web mới mà bạn tạo sẽ tuân theo bộ trải nghiệm giao diện người dùng. Tương tự, tính năng cấp web sẽ thiết lập trải nghiệm giao diện người dùng trên các trang web hiện có.
Làm cách nào để thay đổi dạng xem cổ điển sang dạng xem hiện đại trong SharePoint Online?
Bạn có thể gọi hàm với các tham số liên quan để thay đổi dạng xem cổ điển thành dạng xem hiện đại trong các trang SharePoint. Ví dụ.,
Set-SPOUIExperience -SiteURL $SiteURL -Experience Modern -Scope Site
Tập lệnh PowerShell này thay đổi trải nghiệm giao diện người dùng từ dạng xem cổ điển sang dạng xem hiện đại, cho tất cả các danh sách và thư viện tại tuyển tập trang đã cho. Tuy nhiên, cài đặt nâng cao ở cấp độ danh sách và thư viện riêng lẻ có thể ghi đè cài đặt trên toàn trang. Sử dụng tập lệnh này để cập nhật cài đặt thư viện: SharePoint Online: Làm cách nào để thay đổi giao diện người dùng danh sách thành trải nghiệm hiện đại?
Tương tự, bạn có thể chuyển về trải nghiệm cổ điển từ dạng xem hiện đại trong trang SharePoint Online bằng:
Set-SPOUIExperience -SiteURL $SiteURL -Experience Classic -Scope Site
PnP PowerShell để vô hiệu hóa trải nghiệm cổ điển và kích hoạt giao diện người dùng hiện đại cho trang web
PnP PowerShell giúp việc biến trang web cổ điển thành trang hiện đại trở nên đơn giản hơn nhiều.
#Parmeter
$SiteURL = "https://crescent.sharepoint.com/sites/Marketing/townhall"
#Connect to Site
Connect-PnPOnline -Url $SiteURL -Interactive
#Disable Modern UI Blocking Features at both Site and Web Level
Disable-PnPFeature -Identity "E3540C7D-6BEA-403C-A224-1A12EAFEE4C4" -Scope Site
Disable-PnPFeature -Identity "52E14B6F-B1BB-4969-B89B-C4FAA56745EF" -Scope Web
Xin lưu ý, Bạn cũng phải tắt tính năng này ở cấp trang web, ngay cả khi bạn muốn tắt giao diện người dùng cổ điển ở một trang con cụ thể! (Vì tính năng nằm trong phạm vi tuyển tập trang được kế thừa bởi site con!). Hơn nữa, tập lệnh này không thay đổi bất kỳ trang SharePoint cổ điển nào (bao gồm Trang chủ, Trang phát hành, trang wiki, trang phần web và thư viện trang site) thành các trang hiện đại. Để có được trang chủ hiện đại, Bạn phải sử dụng: Làm cách nào để chuyển đổi trang cổ điển thành trang hiện đại trong SharePoint Online?
Các câu hỏi thường gặp:
Làm cách nào để thay đổi trang hiện đại thành trang cổ điển trong SharePoint Online?
Nếu bạn muốn quay lại trải nghiệm người dùng cổ điển từ các site nhóm hiện đại, hãy sử dụng: SharePoint Online chuyển sang dạng xem cổ điển. Bạn vẫn có thể tạo các trang mới bằng cách sử dụng mẫu trang cổ điển.
Làm cách nào để thay đổi trang gốc thành trang liên lạc hiện đại trong SharePoint Online?
Để thay đổi site gốc (hoặc bất kỳ site nhóm nào) thành site liên lạc, hãy sử dụng lệnh ghép ngắn “Enable-SPOComSite”. Bạn cũng có thể thay thế trang SharePoint cổ điển bằng một trang hiện đại trong Trung tâm quản trị SharePoint.
Thông tin thêm: Chuyển đổi trang gốc thành trang Giao tiếp trong SharePoint Online
Làm cách nào để tạo trang hiện đại trên trang SharePoint Classic?
Để tạo các trang hiện đại trong các trang SharePoint Online Cổ điển: Trước tiên hãy kích hoạt tính năng trong phạm vi web “Trang Trang”. Sau khi bật tính năng này, Bạn sẽ thấy “Trang ” được liệt kê trên trang nội dung Site hoặc trong thư viện “Trang Site” trên trang web của bạn.
Thông tin thêm: SharePoint Online Thêm trang hiện đại vào site cổ điển

