Skip to main content

Get Search Crawl Log using PowerShell 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.

Register an App in Entra ID (Azure AD)

Step 1: Register an App in Entra ID (Azure AD)

  1. Go to: https://entra.microsoft.com

  2. Navigate to: Home > Azure Active Directory > App registrations

  3. Click "New registration".

  4. Provide:

    • Name: PnP-PowerShell-App

    • Supported account types: Leave as Single tenant

    • On the left, select "Authentication" > "Add a platform" > "Mobile and desktop applications"

    • Redirect URI: Leave empty (or set to http://localhost if needed)

    • Scroll to the bottom, find "Allow public client flows" and Enable this option

  5. Click Register.

  6. Copy the Application (client) ID – you’ll need it.

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://rbeerla.sharepoint.com/sites/LearningSite/"

#Azure App Registration Client ID

$ClientId = "e0d998f9-266f-4967-9316-33532b0e475b"

#Connect to PnP Online

Connect-PnPOnline -Url $TenantURL -ClientId $ClientId -Interactive

#Get Search crawl log

Get-PnPSearchCrawlLog

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

We use parameters such as Log Level, Row Limit, Content Source, Filter, Start Date, End Date, etc., to refine crawl log entries. For example, 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://rbeerla.sharepoint.com/sites/LearningSite/"

Get-PnPSearchCrawlLog -RowLimit 100 -Filter "https://rbeerla.sharepoint.com/sites/LearningSite/Lists/Email_Id_Request"

Conclusion

Checking the crawl log in SharePoint Online helps identify and fix search issues. Follow this guide to access the log, review crawled item statuses and errors, and confirm indexing, ensuring users can find the needed content.




Comments

Popular posts from this blog

Get App Expiry Dates using Powershell

Step 1: Connect-MsolService Step 2: $applist = Get-MsolServicePrincipal -all  |Where-Object -FilterScript { ($_.DisplayName -notlike "*Microsoft*") -and ($_.DisplayName -notlike "autohost*") -and  ($_.ServicePrincipalNames -notlike "*localhost*") } Step 3: foreach ($appentry in $applist) {     $principalId = $appentry.AppPrincipalId     $principalName = $appentry.DisplayName     Get-MsolServicePrincipalCredential -AppPrincipalId $principalId -ReturnKeyValues $false | ? { $_.Type -eq "Password" } | % { "$principalName;$principalId;" + $_.KeyId.ToString() +";" + $_.StartDate.ToString() + ";" + $_.EndDate.ToString() } | out-file -FilePath d:\appsec.txt -append }

Bulk Import Excel Data to SharePoint List Using PowerShell and PnP

  Managing large datasets in SharePoint can be tricky, especially when you're dealing with Excel files and need to avoid list view threshold issues. In this guide, I’ll walk you through a PowerShell script that efficiently imports data from Excel into a SharePoint Online list using PnP PowerShell — with batching support for performance. Prerequisites Make sure you have the following before running the script: SharePoint Online site URL Excel file with data properly formatted PnP PowerShell module installed ( Install-Module PnP.PowerShell ) Appropriate SharePoint permissions What the Script Does Connects to your SharePoint site Loads and reads an Excel file Converts Excel date values Batches records in groups (to avoid the 5000 item threshold) Adds the items to your SharePoint list or library Logs execution time PowerShell Script $siteUrl = "[Site Collection URL]" Connect-PnPOnline -Url $siteUrl -UseWebLogin # Capture the start time $startTime...

πŸš€ Essential SPFx (SharePoint Framework) Commands for Every Developer

Whether you're new to SharePoint Framework (SPFx) or a seasoned pro, having a go-to list of core commands can significantly improve your development workflow. In this post, we'll walk through the most important SPFx CLI commands—from setting up your environment to packaging and deploying your solution. πŸ› ️ Setting Up Your SPFx Project Start by scaffolding a new project using the Yeoman generator provided by Microsoft. Make sure Node.js and npm are installed before you proceed. yo @microsoft/sharepoint After scaffolding the project, install all dependencies: npm install To update dependencies later: npm update πŸ” Trusting the Development Certificate If you're using the local workbench, you need to trust the developer certificate for HTTPS support: gulp trust-dev-cert πŸ§ͺ Running the Local Workbench To build and serve your project locally, use: gulp serve This command starts a local server at: https://localhost:4321/temp/workbench.html You can also test your solution in ShareP...