SharePoint Online: Get Search Crawl Log using PowerShell

Requirement: Get search crawl log in SharePoint Online

How to Check the Search Crawl Log in SharePoint Online?
At times, you may have to check the search crawl logs, if search results doesn't return results from a specific content. In SharePoint on-premises environment, search crawl logs can be obtained from Search service application. However, to inspect the search crawl log in SharePoint Online, you have to  use: Get-PnPSearchCrawlLog cmdlet.  make sure you have access to the Crawl Log before you execute any of these PowerShell scripts!
  • Login to SharePoint Online Admin Center
  • Click on "More Features" from the left navigation >> Click on "Open" button under Search
  • In Search Service Application page, Click on "Crawl Log Permissions" link on the bottom >> Enter user names whom you want to grant search crawl log permissions and click on "OK" to save your changes.

PowerShell to Get Search Crawl Log in SharePoint Online
Once you are granted to access crawl logs, use this PnP PowerShell script to get search crawl logs:
#Config Variables
$TenantURL = ""
#Connect to PnP Online
Connect-PnPOnline -Url $TenantURL -UseWebLogin

#Get Search crawl log
This script gets you the last 100 entries from the search crawl logs.
sharepoint online search crawl log
We've parameters such as Log Level, Row Limit, Content Source, Filter, Start Date, End Date, etc to refine crawl log entries. E.g. Let's get the last 10 user profiles crawled in the past 30 days.
Get-PnPSearchCrawlLog -RowLimit 10 -EndDate (Get-Date).AddDays(-30) -ContentSource UserProfiles
We can also filter search crawl log for specific site (or document library) as:
Get-PnPSearchCrawlLog -RowLimit 100 -Filter ""

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.