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 don’t return results from specific content. Search crawl logs can be obtained from the search service application in the SharePoint on-premises environment. However, to inspect the search crawl log in SharePoint Online, you must use Get-PnPSearchCrawlLog cmdlet. Make sure you have access to the Crawl Log before you execute any of these PowerShell scripts!

  1. Login to SharePoint Online Admin Center https://tenant-admin.sharepoint.com
  2. Click on “More Features” from the left navigation >> Click on the “Open” button under the Search.
  3. On the Search Service Application page, click on the “Crawl Log Permissions” link at the bottom >> Enter the 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 access to crawl logs, use this PnP PowerShell script to get search crawl logs:

#Config Variables
$TenantURL = "https://Crescent.sharepoint.com"
 
#Connect to PnP Online
Connect-PnPOnline -Url $TenantURL -Interactive

#Get Search crawl log
Get-PnPSearchCrawlLog

This script gets you the last 100 entries from the search crawl logs.

sharepoint online search crawl log

We have 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 a specific site (or document library) as:

Get-PnPSearchCrawlLog -RowLimit 100 -Filter "https://Crescent.sharepoint.com/sites/marketing"

In summary, checking the crawl log in SharePoint Online is crucial for identifying and troubleshooting issues with your search results. By following the steps outlined in this guide, you should now be able to access the crawl log and view important information such as the status of crawled items, any errors that were encountered, and ensure if a specific items were successfully indexed. This information can be used to optimize your search results and ensure that users are able to find the content they are looking for.

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

One thought on “SharePoint Online: Get Search Crawl Log using PowerShell

  • Great.
    Any idea how to use it with app only authentication?

    Ty.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *