当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] SharePoint Online:使用 PowerShell 在现代网站中禁用页面评论

作者:精品下载站 日期:2024-12-14 21:11:53 浏览:16 分类:玩电脑

SharePoint Online:使用 PowerShell 在现代网站中禁用页面评论


要求:禁用 SharePoint Online 现代网站和通信网站中的页面注释。

[玩转系统] SharePoint Online:使用 PowerShell 在现代网站中禁用页面评论

如何在 SharePoint Online 中禁用页面评论?

SharePoint Online 中的新式页面在每个页面底部都有一个注释部分,以便更好地协作。评论是与他人互动并获取有关您的内容的反馈的好方法。但是,有时您可能希望禁用 SharePoint Online 中页面的注释。在本文中,我们将向您展示如何做到这一点。

选项 1:在租户级别禁用评论

可以通过以下设置在租户级别关闭页面评论:

  1. 导航到 SharePoint Online 管理中心:https://yourdomain-admin.sharepoint.com
  2. 单击左侧导航中的“设置”
  3. 在“设置”页面上,选择“禁用网站页面评论”。

    [玩转系统] SharePoint Online:使用 PowerShell 在现代网站中禁用页面评论

  4. 单击“确定”保存更改。

在现代管理中心中,这被移动到:

  1. 设置>>页面>>“允许在新式页面上发表评论”

    [玩转系统] SharePoint Online:使用 PowerShell 在现代网站中禁用页面评论

稍等片刻,您将看到租户中所有页面的评论部分均被禁用。您还可以使用 PowerShell 在租户级别禁用新式页面上的评论。

SharePoint Online:默认关闭评论

使用此 PowerShell 在租户范围内禁用 SharePoint Online 中的页面注释:


$AdminCenterURL="https://crescent-admin.sharepoint.com"

#Connect to SharePoint Online
Connect-SPOService -Url $AdminCenterURL -Credential (Get-Credential)

#Disable Comments on Site Pages at Tenant Level
Set-SPOTenant -CommentsOnSitePagesDisabled $True

选项 2:在页面级别禁用评论

可以在页面级别禁用评论。具体方法如下:

  1. 导航到 SharePoint Online 网站页面 >> 编辑页面。
  2. 通过将开关从“开”位置切换到“关”位置来关闭评论并发布页面。

    [玩转系统] SharePoint Online:使用 PowerShell 在现代网站中禁用页面评论

这会禁用特定页面上的评论部分。

选项 3:使用 PowerShell 禁用 SharePoint Online 页面中的评论

此 PowerShell 脚本禁用给定站点的页面评论:


#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
 
#Config Parameters
$SiteURL="https://crescent.sharepoint.com/sites/GroupIT"
 
Try {
    #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 Web
    $Web = $ctx.Web
    $Ctx.Load($Web)
    $Ctx.ExecuteQuery()

    #Disable Comments in Site Pages
    $Web.CommentsOnSitePagesDisabled = $True
    $Web.Update()
    $Ctx.ExecuteQuery()
    Write-host -f Green "Page Comments has been disabled Successfully!"
}
Catch {
    write-host -f Red "Error:" $_.Exception.Message
}

请注意,禁用评论不会删除页面上现有的评论,而只是隐藏它们。打开评论可以恢复评论!

PnP PowerShell 禁用库中所有页面的评论


#Parameter
$SiteURL= "https://crescent.sharepoint.com/sites/marketing/2018"
$LibraryName = "SitePages"

#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)

#Get all Pages from the Library
$Pages = Get-PnPListItem -List $LibraryName | Where { $_.FileSystemObjectType -eq "File"}

#Loop through each Page 
ForEach($Page in $Pages)
{
    #Disable Comments
    Write-host "Disabling Comments on page:"$Page["FileLeafRef"]
    Set-PnPPage -Identity $Page["FileLeafRef"] -CommentsEnabled:$False
}

结论

在现代 SharePoint Online 网站中禁用页面评论是防止不需要或不适当的评论的简单而有效的方法。通过自动化流程,管理员可以快速轻松地禁用多个站点的评论,确保 SharePoint 环境中的内容和协作保持安全和受控。无论您是禁用一页、网站中的所有页面还是租户的注释,本指南都将帮助您使用 PowerShell 在 SharePoint Online 中快速轻松地禁用页面注释。

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯