The script here resets the SharePoint 2010 search index, which I have posted as there is no out-of-the-box cmdlet for doing this. This effectively does the same thing as the Index Reset option for the search service application in Central Administration:
Note there are two parameters you can specify in the Reset method:
- Disable alerts: $true if the Search alerts should be disabled during reset; otherwise, $false. Selecting $true here is the same as ticking the “Deactivate search alerts during reset” checkbox shown in the screenshot above.
- Ignore unreachable server: $true if the failures to connect to servers are ignored; otherwise, $false.
In the script example I have added below, both options are set to $false. Note that running this script will permanently delete all crawled data in the search service application – you will need to re-crawl your content sources to get it back.
#Get the search service application
#You will need to specify the -Identity switch and a name if you have more than one
$sa = Get-SPEnterpriseSearchServiceApplication
#Reset index with the following options in brackets:
#Disable Alerts $true/$false
#Ignore unreachable server $true/$false
Write-Host "Attempting to reset the index...please wait"
Write-Host "Index successfully reset" -ForegroundColor Blue
Write-Host "There was a problem resetting the index:" $_ -ForegroundColor Red