How to Update Managed Property as Searchable, Queryable, Sortable, Refinable, Retrievable in SharePoint 2013 using PowerShell

Sathish Nadarajan
 
Solution Architect
February 3, 2015
 
Rate this article
 
Views
20343

In the previous article, we saw How to create a Managed Property in SharePoint 2013 using PowerShell.

In this article, let us see how to Update Managed Property with various properties.

The script is as follows.

 $LogTime = Get-Date -Format yyyy-MM-dd_hh-mm
 $LogFile = ".UpdateManagedPropertyPatch-$LogTime.rtf"
 
 #start-transcript $logfile
 
 # Add SharePoint PowerShell Snapin
 
 
 if ( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null ) {
     Add-PSSnapin Microsoft.SharePoint.Powershell
 }
 
 $scriptBase = split-path $SCRIPT:MyInvocation.MyCommand.Path -parent
 Set-Location $scriptBase
 
 $OutputPath = $scriptBase + "" + "ManagedPropErrors.txt"
 
 
 if (test-path $OutputPath)
 {
     remove-item $OutputPath
 }
 
 
 $csvfile = $scriptBase + "" + "EditManagedProp.csv"
 Import-csv $csvfile | where {
 
 $searchapp = Get-SPEnterpriseSearchServiceApplication
 
 $ManagedProperty = Get-SPEnterpriseSearchMetadataManagedProperty -SearchApplication $searchapp -Identity $_.ManagedPropertyName -ea silentlycontinue
 
 if($ManagedProperty)
 {
     $ManagedProperty.Searchable = $true
     $ManagedProperty.Queryable = $true
     $ManagedProperty.Sortable = $true
     $ManagedProperty.Retrievable = $true
     $ManagedProperty.Refinable = $true
     $ManagedProperty.SafeForAnonymous = $true
     $ManagedProperty.update()
     write-host "The searchable, queryable, Sortable, Retrievable and Refinable for the managed property" $_.ManagedPropertyName "has been enabled successfully ...... Done !" -fore green
 }
 else
 {
     Write-Host -f Yellow "The specified managed property " $_.ManagedPropertyName " does not exists... Please check whether you have given valid managed property name"
     $a = "The specified managed property " + $_.ManagedPropertyName + " does not exists... Please check whether you have given valid crawled property name"| out-file $OutputPath -append
 }
 
 
 }
 #stop-transcript 
 

DOWNLOAD HERE

Happy Coding.

Sathish Nadarajan.

Author Info

Sathish Nadarajan
 
Solution Architect
 
Rate this article
 
Sathish is a Microsoft MVP for SharePoint (Office Servers and Services) having 15+ years of experience in Microsoft Technologies. He holds a Masters Degree in Computer Aided Design and Business ...read more
 

Leave a comment