Wednesday, September 21, 2011

Adding Mapping to Managed Metadata Properties

I've been tasked to write script for configuring search filter for custom user profile properties to deploy to production environment. The powershell script below can do the job to configure the mapping.

$searchapp = Get-SPEnterpriseSearchServiceApplication "Search Service Application"

$cat = Get-SPEnterpriseSearchMetadataCategory -SearchApplication $searchapp -Identity People

$crawledproperty=Get-SPEnterpriseSearchMetadataCrawledProperty -SearchApplication $searchapp -Category $cat -Name "urn:schemas-microsoft-com:sharepoint:portal:profile:DrivingLicenseClass"

$managedproperty = New-SPEnterpriseSearchMetadataManagedProperty -SearchApplication $searchapp -Name "DrivingLicenseClass" -Type 1

New-SPEnterpriseSearchMetadataMapping -SearchApplication $searchapp -ManagedProperty $managedproperty -CrawledProperty $crawledproperty