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

[玩转系统] SharePoint Online:如何使用 PowerShell 重新索引列表或文档库?

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

SharePoint Online:如何使用 PowerShell 重新索引列表或文档库?


要求: 使用 PowerShell 的 SharePoint Online 重新索引列表或文档库。

[玩转系统] SharePoint Online:如何使用 PowerShell 重新索引列表或文档库?

如何在 SharePoint Online 中重新索引列表或文档库?

当您遇到搜索问题(例如缺少项目或搜索结果不完整)时,可能需要在 SharePoint Online 中重新索引列表或文档库。重新索引可以帮助重建搜索索引并确保所有内容都正确索引并可搜索。在本文中,我们将介绍如何在 SharePoint Online 中重新索引列表或文档库,并提供分步说明和 PowerShell。

第 1 步:导航至列表或库设置

首先,导航到要重新索引的列表或库,然后单击右上角的齿轮图标。从下拉菜单中选择“列表设置”或“库设置”。

第 2 步:重新索引列表或库

进入列表或库设置后,向下滚动到“常规设置”部分,然后单击“高级设置”。在“重新索引文档库”或“重新索引列表”下,单击“重新索引”按钮以启动重新索引过程。

[玩转系统] SharePoint Online:如何使用 PowerShell 重新索引列表或文档库?

通过执行这些步骤,您可以在 SharePoint Online 中重新索引列表或文档库。这有助于确保所有内容都正确索引和可搜索,从而降低丢失项目或搜索结果不完整的风险。重新索引过程完成后(可能在六个小时内),您应该验证搜索结果是否准确且完整。

PowerShell 在 SharePoint Online 中重新索引列表

尽管完全爬网按计划对 SharePoint 中的项目进行完全索引,但 SharePoint 中的重新索引功能有助于在下一次增量或连续爬网期间重新爬网并执行完整索引。这篇博文将向您展示如何重新索引 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"
  
#Variables for Processing
$SiteUrl = "https://Crescent.sharepoint.com"
$ListName="Projects"

#Setup 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 the List Root Folder
    $List=$Ctx.web.Lists.GetByTitle($ListName)
    $Ctx.Load($List)
    $Ctx.Load($List.RootFolder)
    $Ctx.Load($List.RootFolder.Properties)
    $Ctx.ExecuteQuery()

    [Int] $SearchVersion = 0
    #Get the existing search version number
    If($List.RootFolder.Properties.FieldValues.ContainsKey("vti_searchversion") -eq $True)
    {
        $SearchVersion = $List.RootFolder.Properties["vti_searchversion"]
    }
 
    #Increment Search version
    $SearchVersion++

    #Update the Search version number
    $List.RootFolder.Properties["vti_searchversion"] = $SearchVersion
    $List.RootFolder.Update()
    #$List.Update()
    $Ctx.ExecuteQuery()
    
    Write-Host -f Green "Search Version Set to '$SearchVersion' and List '$ListName' marked for Reindex Successfully!"
    
}
Catch {
    write-host -f Red "Error:" $_.Exception.Message
} 

PnP PowerShell 在 SharePoint Online 中重新索引列表

使用 PnP PowerShell cmdlet Request-PnPReIndexList 重新索引 SharePoint Online 列表或库:


#Config Variables
$SiteURL = "https://Crescent.sharepoint.com"
$ListName="Projects"

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

#Request Reindex
Request-PnPReIndexList -Identity $ListName 

如何在 SharePoint Online 中重新索引网站?具体方法如下:如何重新索引 SharePoint Online 网站?

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

取消回复欢迎 发表评论:

关灯