When we have a look into the Site Settings > Search and Offline Availability, we see a button to give us the availability to reindex this site.

Doing the same in PowerShell is not that tricky. All we have to do is, to increment the value of the key “vti_searchversion” in the AllProperties collection of the SPWeb object.

param (
    [string] $url
)

$web = Get-SPWeb $url

[int] $version = 0

$propertyBag = $web.AllProperties

if ($propertyBag.ContainsKey("vti_searchversion") -eq $true)
{
    $version = $propertyBag["vti_searchversion"]
}

$version++

$web.AllProperties["vti_searchversion"] = $version
$web.Update()

Write-Host -ForegroundColor Green "Done."

As I have seen in some investigation, the important part in the script is to initialize the $version variable as an int.

Advertisements