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

[玩转系统] SharePoint Online:将默认搜索范围从“搜索此网站”更改为“搜索所有网站”

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

SharePoint Online:将默认搜索范围从“搜索此网站”更改为“搜索所有网站”


要求:在 SharePoint Online 网站中配置搜索范围。

如何更改 SharePoint Online 中的默认搜索范围?

SharePoint Online 中的默认搜索范围是“搜索此网站”,这允许我们在特定网站集中进行搜索。有时,您可能希望将搜索范围从“搜索此网站”更改为“搜索所有网站”。如果您想要搜索所有网站集,或者想要搜索网站集之外的内容,这会很有用。在本文中,我们将向您展示如何更改 SharePoint Online 中的搜索范围。

[玩转系统] SharePoint Online:将默认搜索范围从“搜索此网站”更改为“搜索所有网站”

使用 PowerShell 在 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()

    #Set search scope for the web to global
    $Web.SearchScope = 1
    $web.Update()
    $Ctx.ExecuteQuery()
}
Catch {
    write-host -f Red "Error:" $_.Exception.Message
}

这会将给定 SharePoint Online 网站的搜索范围从“搜索此网站”更改为“在 SharePoint 中搜索”(全局搜索)。

[玩转系统] SharePoint Online:将默认搜索范围从“搜索此网站”更改为“搜索所有网站”

搜索范围枚举值:

  • 默认范围=0
  • 租户=1
  • 集线器=2
  • 站点=3

使用 PnP PowerShell 在 SharePoint Online 中配置搜索范围

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


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

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

#change default search scope
Set-PnPSearchSettings -SearchScope Tenant

这会将搜索范围从本地站点更改为全局搜索。如果要更新多个网站集,您可以循环浏览它们并应用这些设置,也可以使用 CSV 文件有选择地更改搜索范围。

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

取消回复欢迎 发表评论:

关灯