Is there any powershell script to set a search query rule inactive?
I have to inactivate the query rule "People Name in sharepoint search"
using powershell
script.
1 Answer
$web = Get-SPweb http://sharePoint
$own = "SPSite" #Possible values are SPWeb, SPSite, SSA. SSA does not need a spweb object
$ssa = Get-SPEnterpriseSearchServiceApplication
#$srchObjOwn = New-Object Microsoft.Office.Server.Search.Administration.SearchObjectOwner("SSA")
$srchObjOwn = New-Object Microsoft.Office.Server.Search.Administration.SearchObjectOwner($own,$web)
$srchObjFilt = New-Object Microsoft.Office.Server.Search.Administration.SearchObjectFilter($srchObjOwn)
$ruleMgr = New-Object Microsoft.Office.Server.Search.Query.Rules.QueryRuleManager($ssa)
$qryRules = $ruleMgr.GetQueryRules($srchObjFilt)
$rule = $qryRules["RuleName"]
$rule[0].IsActive = $false
$rule[0].Update()
-
you should call UpdateActiveStatus() if query rule is read-only.– Tany3450Commented May 31, 2019 at 8:03