Créer un site internet

Add task to reset sharepoint search index with powershell

fredericdietrich By On 05/10/2018

Create a powershell script (task1.ps1) with code below


if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null)
{
    Add-PSSnapin Microsoft.SharePoint.PowerShell -Verbose -ErrorAction:Stop
}
#the $True parameter denotes: Disable Alerts and Ignore Timeout error.
(Get-SPEnterpriseSearchServiceApplication).reset($true, $true)

Add a new task in your task scheduler

Check the radio button 'Run whether user is logged on or not

Set a name and add a trigger to set scheduling

set the action : program / script

	
		%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe
	
	

argument with -command followed by the pass to your powershell script

	
		-executionpolicy unrestricted -command D:\PS1\Task1.ps1
	
	

Save your task

 

reset indexes of one content source only

 

powershell Sharepoint Search

  • 2 votes. Average: 5 / 5.