Create Managed Property In Sharepoint 2013 Using Powershell Script

In this blog, we will learn about the default managed properties, their settings, and the default mapping between crawled and managed properties creation using PowerShell.

Managed Property

Managed properties can have a large number of settings or attributes. These attributes determine how the contents are shown in the search results.

For more details about the Properties, go to https://technet.microsoft.com/en-us/library/jj219630.aspx

Powershell Script
  1. #Search Service Application  
  2. $category = Get - SPEnterpriseSearchMetadataCategory– SearchApplication $searchapp– Identity $_.Category  
  3. $property = Get - SPEnterpriseSearchMetadataCrawledProperty - SearchApplication $searchapp - name $_.CrawledPropertyName - Category $category - ea silentlycontinue   
  4. # If the Crawled Property is present  
  5. if ($property) {  
  6.     #Check Managed Property already exists  
  7.     $ManagedProperty = Get - SPEnterpriseSearchMetadataManagedProperty - SearchApplication $searchapp - Identity $_.ManagedPropertyName - ea silentlycontinue  
  8.     if ($ManagedProperty) {  
  9.         Write - Host - f green” Cannot create managed property” $_.ManagedPropertyName“ Already exists”  
  10.     } else {  
  11.         #Create Managed Property  
  12.         New - SPEnterpriseSearchMetadataManagedProperty - Name $_.ManagedPropertyName - SearchApplication $searchapp - Type $_.Type - Description $_.Description  
  13.         $ManagedProperty = Get - SPEnterpriseSearchMetadataManagedProperty - SearchApplication $searchapp - Identity $_.ManagedPropertyName  
  14.         # Map the Managed Property with the Crawled Property  
  15.         New - SPEnterpriseSearchMetadataMapping - SearchApplication $searchapp - ManagedProperty $ManagedProperty– CrawledProperty $property  
  16.     }  
  17. }  
Conclusion

Was my blog helpful? If yes, please let me know and if not, please explain what was confusing or missing. I’ll use your feedback to double-check the facts, add info, and update this blog.