Trigger a Full Crawl on SharePoint Online


Mikael Svenson wrote a cool script which will iterate all site collections, sites and sub-sites on your tenant to force a trigger of re-indexing / full crawl of all items on the next crawl.

In SharePoint Online we cannot force a full crawl via the admin user interface and thus have to iterate all sites and set a property in the property bag to accomplish the same task:

function processWeb($web) {

    $subWebs = $web.Webs

    Write-Host "Web URL:" $web.Url -ForegroundColor White
    if( $enableAllManagedProperties -ne "skip" ) {
        Set-AllManagedProperties -web $web -clientContext $clientContext -enableAllManagedProps $enableAllManagedProperties

    [int]$version = 0
    $allProperties = $web.AllProperties
    if( $allProperties.FieldValues.ContainsKey("vti_searchversion") -eq $true ) {
        $version = $allProperties["vti_searchversion"]
    $allProperties["vti_searchversion"] = $version
    Write-Host "-- Updated search version: " $version -ForegroundColor Green

    foreach ($subWeb in $subWebs)

This is needed for several search schema modifications, for example when you map crawled properties to managed properties.

The script also has a function to enable population of the ManagedProperties managed property for use with the SharePoint 2013 Search Query Tool v2.

You can download the script here:

Get in Touch!

Matthew Stark

Founder, Making Things Work

Let's talk about your project & how I can help! Reach out at the below coordinates.

Connect on Linkedin read more about Matt »

Top Tags