3

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 1

5
$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()
1
  • you should call UpdateActiveStatus() if query rule is read-only.
    – Tany3450
    Commented May 31, 2019 at 8:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.