# encoding: ascii
# api: powershell
# title:
# description: Update SharePoint Search scopes, useful when revving the Scope definitions.
# version: 0.1
# type: function
# license: CC0
# function: Update-Scopes
# x-poshcode-id: 925
# x-archived: 2017-04-30T10:36:08
#
#
function Update-Scopes($siteUrl)
{
[void][reflection.assembly]::Loadwithpartialname("Microsoft.SharePoint") | out-null
[void][reflection.assembly]::Loadwithpartialname("Microsoft.office.server.search") | out-null
$s = [microsoft.sharepoint.spsite]$siteUrl
$sc = [microsoft.office.server.servercontext]::GetContext($s)
$search = [Microsoft.Office.Server.Search.Administration.SearchContext]::GetContext($sc)
$scopes = [microsoft.office.server.search.administration.scopes]$search
$scopes.StartCompilation()
while ($scopes.CompilationPercentComplete -lt 100) { sleep -seconds 3; write-host "$($scopes.CompilationPercentComplete)% complete" }
}
#usage: paste this text into your PowerShell window, then call the "Update-Scopes" function as noted below
Update-Scopes -siteUrl "http://dev/sites/MySPSite/"