Creating Managed & Crawled Properties using PowerShell

Have you ever created and mapped a decent amount of managed properties in SharePoint using the UI? If you have, you probably know that it’s not the most exciting job. Lots of clicking, waiting, reloading,…

If you are someone like me… someone who doesn’t like doing things manually… and you are reading this, you are probably expecting to find an automated way of creating those things. And you will not be dissappointed. I’ll even throw in something extra: add “crawled properties”.
Normally, crawled properties are added during the crawling process. I’ll show you how you can add those properties manually using PowerShell without having the need to kick-off a crawl before those properties show up.

Configuration File

First of all, the script which is shown here, requires an XML file which has the crawled and managed properties you want to add. You can find a sample of such an XML below.

To find the values you need to provide for the different attributes, you can look at the documentation for New-SPEnterpriseSearchMetadataCrawledProperty and New-SPEnterpriseSearchMetadataManagedProperty.

Script

Once you have this file, you can feed it into the following script: