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

[玩转系统] SharePoint Online:如何禁用文档库中的“同步”按钮?

作者:精品下载站 日期:2024-12-14 14:41:01 浏览:17 分类:玩电脑

SharePoint Online:如何禁用文档库中的“同步”按钮?


要求:禁用 SharePoint Online 或 OneDrive for Business 文档库中的“同步”按钮。

[玩转系统] SharePoint Online:如何禁用文档库中的“同步”按钮?

如何禁用 SharePoint Online 文档库中的同步按钮?

您是否正在寻找一种在 SharePoint Online 中禁用同步的方法?也许您遇到性能问题或同步错误,并且您想尝试禁用同步以查看是否有帮助。本文将向您展示如何在 SharePoint Online 中禁用同步。

要禁用单个库的同步按钮,请按照下列步骤操作:

  1. 转到:库设置>>高级设置
  2. 将“离线客户端可用性”设置为“否”

    [玩转系统] SharePoint Online:如何禁用文档库中的“同步”按钮?

这会禁用库中的“同步”按钮。

PnP PowerShell 在 SharePoint Online 库中禁用同步:

当您不希望用户能够同步文档库中的文档时,请使用此 PowerShell!


#Parameters
$SiteURL = "https://crescent.sharepoint.com/sites/Marketing"
$ListName = "Branding"

#Connect to PnP
Connect-PnPOnline -url $SiteURL -Interactive

#Get the Library
$List = Get-PnPList $ListName

#Exclude List or Library from Sync
$List.ExcludeFromOfflineClient = $true
$List.Update()
Invoke-PnPQuery

在 SharePoint Online 网站中禁用同步

如果您不需要用户在其设备上拥有离线副本,或者您担心意外删除或修改文件,则禁用同步功能是个好主意。要在 SharePoint Online 网站中禁用同步,只需执行以下步骤:

如果您想禁用整个网站的同步,

  1. 转到站点设置 >> 单击“搜索”组下的“搜索和离线可用性”。
  2. 将“脱机客户端可用性”设置设为“否”。

    [玩转系统] SharePoint Online:如何禁用文档库中的“同步”按钮?

这会隐藏 SharePoint Online 中所有库的同步按钮。

使用 PnP PowerShell 设置搜索和离线可用性

有时,您可能希望禁用整个站点的同步。通过执行以下步骤可以快速完成此操作。若要禁用 SharePoint Online 中的同步按钮,请使用此 PowerShell 脚本。


#Parameters
$SiteURL = "https://Crescent.sharepoint.com/sites/Marketing"

#Connect to SharePoint Online site
Connect-PnPOnline -Url $SiteURL -Interactive

#Get the Web
$Web = Get-PnPWeb -Includes ExcludeFromOfflineClient

#Set "Allow items from this site to be downloaded to offline clients?" to "No"
$web.ExcludeFromOfflineClient = $True
$web.Update()
Invoke-PnPQuery
Write-Host "Offline Client Availability is Disabled!" -f Green

请注意,此设置是在“网站”级别,而不是网站集级别,并且需要在网站集的所有网站上进行设置,因此让我们使用 PowerShell 在 SharePoint Online 网站集中的所有网站上禁用同步!

PowerShell 用于删除网站集所有网站中的同步按钮

让我们隐藏 SharePoint Online 网站集的同步按钮。


#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"

Function Disable-SPOSyncButton([String]$SiteURL)
{  
    Try{
        #Setup the context
        $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
        $Ctx.Credentials = $Credentials

        #Get the Web and Sub Sites
        $Web = $Ctx.Web
        $Ctx.Load($Web)
        $Ctx.Load($Web.Webs)
        $Ctx.ExecuteQuery()

        $Web.ExcludeFromOfflineClient=$true
        $Web.Update()
        $Ctx.ExecuteQuery()
        Write-Host -f Green "Sync Button is Disabled for the Site:" $($SiteURL)

        #Iterate through each subsite of the current web
        ForEach ($Subweb in $Ctx.Web.Webs)
        {
            #Call the function recursively 
            Disable-SPOSyncButton -SiteURL $Subweb.url
        }
    }
    Catch {
        write-host -f Red "Error Disabling Sync Button!" $_.Exception.Message
    }
}

#Set parameter values
$SiteURL="https://crescent.sharepoint.com/"

#Get Credentials to connect
$Cred= Get-Credential
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)

#Call the function 
Disable-SPOSyncButton -SiteURL $SiteURL

要在 OneDrive for Business 网站中禁用同步,请使用:如何在租户级别隐藏 OneDrive for Business 中的同步?

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

取消回复欢迎 发表评论:

关灯