PoshCode Archive  Artifact [e06b9c186f]

Artifact e06b9c186f2933a914e04d913c96e64d7823d775f8a436e83bfdd90682596e6f:

  • File Update-Scopes.ps1 — part of check-in [03a52b878e] at 2018-06-10 14:26:55 on branch trunk — Update SharePoint Search scopes, useful when revving the Scope definitions. (user: unknown size: 1108)

# 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/"