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

[玩转系统] SharePoint Online:隐藏顶部导航套件栏中的搜索框

作者:精品下载站 日期:2024-12-14 15:42:13 浏览:13 分类:玩电脑

SharePoint Online:隐藏顶部导航套件栏中的搜索框


要求:隐藏 SharePoint Online 顶部导航套件栏中的搜索框。

[玩转系统] SharePoint Online:隐藏顶部导航套件栏中的搜索框

如何从顶部导航套件栏中删除搜索框?

在 SharePoint Online 中,搜索栏是一项有用的功能,允许用户在平台内快速查找内容和文档。但是,在某些情况下,您可能希望隐藏整个网站的搜索栏。在本指南中,我们将讨论如何在 SharePoint Online 中隐藏搜索栏的步骤。

可以使用以下 PowerShell 脚本隐藏 SharePoint Online 顶部导航套件栏中的搜索框:


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

#Get Credentials to connect
$Cred = Get-Credential

Try {
    #Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)
 
    #Get Web object
    $Web = $Ctx.Web
    $Ctx.Load($Web)
    $Ctx.ExecuteQuery()

    #Disable search in the navigation bar
    $Web.SearchBoxInNavBar = 3
    $web.Update()
    $Ctx.ExecuteQuery()
}
Catch {
    write-host -f Red "Error:" $_.Exception.Message
}

SearchBoxInNavBar 枚举值:

  • 继承=0
  • 所有页面=1
  • 仅现代=2
  • 隐藏=3

我们还可以使用 PnP PowerShell 设置搜索框设置。


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

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

#Hide Searchbox in the Navigation bar
Set-PnPSearchSettings -SearchBoxInNavBar Hidden -Scope Web -Force

这会在几分钟内隐藏 SharePoint Online 网站顶部导航栏中的搜索框。要在导航栏中启用搜索框,请使用:


Set-PnPSearchSettings -SearchBoxInNavBar ModernOnly -Scope Web

此外,您还可以通过将范围参数从“Web”更改为“Site”来设置网站集级别的搜索框可见性

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

取消回复欢迎 发表评论:

关灯