Skip to content
Rishan Solutions
Rishan Solutions
  • PowerApps
  • SharePoint online
    • Uncategorized
    • Uncategorized
  • PowerAutomate
Rishan Solutions
Latest Posts
  • Agentic AI: The Dawn of Autonomous Intelligence Revolutionizing 2025 June 24, 2025
  • Recursive Queries in T-SQL May 7, 2025
  • Generating Test Data with CROSS JOIN May 7, 2025
  • Working with Hierarchical Data May 7, 2025
  • Using TRY_CAST vs CAST May 7, 2025
  • Dynamic SQL Execution with sp_executesql May 7, 2025

Optimizing SharePoint Online Search Performance using PnP PowerShell

Posted on March 21, 2025March 25, 2025 by Rishan Solutions

Loading

SharePoint Online Search Performance plays a crucial role in retrieving relevant content quickly. Poor search performance can result from large datasets, missing metadata, outdated search indexes, or inefficient query rules.

Using PnP PowerShell, we can optimize search by:
Managing search indexes
Creating query rules
Improving search schema
Refining search results


Step 1: Connect to SharePoint Online

To optimize SharePoint search, first, connect to your site.

$siteUrl = "https://yourtenant.sharepoint.com/sites/YourSite"
Connect-PnPOnline -Url $siteUrl -Interactive

βœ” Ensures secure authentication.


Step 2: Check Search Index Status

Before optimizing, check if content is being properly indexed.

Get-PnPSearchCrawlLog -StartDate (Get-Date).AddDays(-7) -EndDate (Get-Date)

βœ” Shows indexed items and crawl errors.


Step 3: Reindex a SharePoint List or Library

If search isn’t picking up new content, force a reindex.

Set-PnPList -Identity "Documents" -NoCrawl $false
Write-Host "πŸ”„ Reindex triggered for Documents library"

βœ” Ensures new content appears in search.


Step 4: Remove Unwanted Content from Search

To prevent unwanted data from appearing in search, exclude a list:

Set-PnPList -Identity "OldRecords" -NoCrawl $true
Write-Host "🚫 OldRecords library is now excluded from search results"

βœ” Helps improve search relevance.


Step 5: Optimize Search Schema

Improve search by mapping managed properties.

Add-PnPSearchManagedProperty -Name "CustomMetadata" -Type Text -Retrievable
Write-Host " CustomMetadata added to search schema"

βœ” Enhances metadata-based filtering.


Step 6: Create Search Query Rules

Boost certain results by creating a query rule.

Add-PnPSearchQueryRule -Name "Promote HR Documents" -Query "HR Policies" -PromotedResultTitle "HR Portal" -PromotedResultUrl "https://yourtenant.sharepoint.com/sites/HR"
Write-Host "🎯 HR search query rule added"

βœ” Improves search ranking.


Step 7: Increase Search Query Speed

Reduce search latency by enabling FAST search results.

Set-PnPSearchConfiguration -Identity "SiteSearch" -Configuration @"
{
"EnableQueryRules": true,
"EnableSummaries": true
}
"@
Write-Host "⚑ Search query optimization applied"

βœ” Speeds up search response times.


Step 8: Schedule Regular Search Index Resets

To clear outdated data, reset the search index.

Submit-PnPSearchQuery -Query "*"
Write-Host "πŸ” Search index refreshed"

βœ” Prevents stale results.


Step 9: Automate Search Optimization (Optional)

Run the optimization script weekly via Task Scheduler:

1️⃣ Save script as OptimizeSearch.ps1
2️⃣ Open Task Scheduler β†’ Create Task
3️⃣ Trigger β†’ Weekly
4️⃣ Action β†’ Start program β†’ powershell.exe -File C:\Scripts\OptimizeSearch.ps1
5️⃣ Ensure script execution policy:

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

βœ” Keeps search performance optimized automatically.

Posted Under PNP PowerShellAutomation Indexing Metadata Microsoft 365 Performance PNP PowerShell Query Rules Search Optimization SharePoint online

Post navigation

Java API Rate Limiting Strategies
Automating Content Expiration and Cleanup using PnP PowerShell

Leave a Reply Cancel reply

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

Recent Posts

  • Agentic AI: The Dawn of Autonomous Intelligence Revolutionizing 2025
  • Recursive Queries in T-SQL
  • Generating Test Data with CROSS JOIN
  • Working with Hierarchical Data
  • Using TRY_CAST vs CAST

Recent Comments

  1. Michael Francis on Search , Filter and Lookup in power apps
  2. A WordPress Commenter on Hello world!

Archives

  • June 2025
  • May 2025
  • April 2025
  • March 2025
  • February 2025
  • March 2024
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • June 2023
  • May 2023
  • April 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • January 2022

Categories

  • Active Directory
  • AI
  • AngularJS
  • Blockchain
  • Button
  • Buttons
  • Choice Column
  • Cloud
  • Cloud Computing
  • Data Science
  • Distribution List
  • DotNet
  • Dynamics365
  • Excel Desktop
  • Extended Reality (XR) – AR, VR, MR
  • Gallery
  • Icons
  • IoT
  • Java
  • Java Script
  • jQuery
  • Microsoft Teams
  • ML
  • MS Excel
  • MS Office 365
  • MS Word
  • Office 365
  • Outlook
  • PDF File
  • PNP PowerShell
  • Power BI
  • Power Pages
  • Power Platform
  • Power Virtual Agent
  • PowerApps
  • PowerAutomate
  • PowerPoint Desktop
  • PVA
  • Python
  • Quantum Computing
  • Radio button
  • ReactJS
  • Security Groups
  • SharePoint Document library
  • SharePoint online
  • SharePoint onpremise
  • SQL
  • SQL Server
  • Template
  • Uncategorized
  • Variable
  • Visio
  • Visual Studio code
  • Windows
Β© Rishan Solutions 2025 | Designed by PixaHive.com.
  • Rishan Solutions