I'm trying to find a way to deploy search managed properties via script to my Office 365 SharePoint tenant.

Previously, for on-prem SharePoint I've achieved this using PowerShell - fairly straight forward.

However for SharePoint Online, I know the PowerShell commands are extremely limited so I have investigated using CSOM.

I've looked through the following DLL, but can't find any useful methods

c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Search.dll

Does anyone know if this is possible, or is it only possible from the UI?

  • i went through a post. and i think it will help you on achieving this. Check this post darkomilevski.info/blog/?p=18 Commented Aug 5, 2015 at 4:59
  • Hi .Were you able to find a solution for this
    – Anil
    Commented Oct 17, 2016 at 20:11

2 Answers 2


ChathuraSam hasnt understood the question as his comment relates to running a search using a managed property that has already been created whereas the question is clearly about creating managed properties using CSOM. Unfortunately I dont have enough reputation to comment.

I believe the way to do this (although I havent tried this myself) is with SearchConfigurationPortability. And then a snippet of how you'd do this with an export would be (taken from here):

#Please install the SharePoint client components SDK - http://www.microsoft.com/en-us/download/details.aspx?id=35585 prior to running this script.

#Specify tenant admin, site URL and scope to export from
$User = "[email protected]"
$SiteURL = https://tenant.sharepoint.com/sites/site
$Scope = "SPSite"
$Schema = "D:\SearchSchema.XML"

#Add references to SharePoint client assemblies and authenticate to Office 365 site - required for CSOM
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Search.dll"

$Password = Read-Host -Prompt "Please enter your password" -AsSecureString
$Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($User,$Password)

#Export search configuration
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Context.Credentials = $Creds
$Owner = New-Object Microsoft.SharePoint.Client.Search.Administration.SearchObjectOwner($Context,$Scope)
$Search = New-Object Microsoft.SharePoint.Client.Search.Portability.SearchConfigurationPortability($Context)
$SearchConfig = $Search.ExportSearchConfiguration($Owner)
$SearchConfig.Value > $Schema

And then an import would be (taken from here):

$searchConfigurationPortability = New-Object Microsoft.SharePoint.Client.Search.Portability.SearchConfigurationPortability($clientContext)
$owner = New-Object Microsoft.SharePoint.Client.Search.Administration.SearchObjectOwner($clientContext, $configScope)

[xml]$searchConfigXml = Get-Content $pathToSearchSchemaXmlFile
$searchConfigurationPortability.ImportSearchConfiguration($owner, $searchConfigXml.OuterXml)
  • Hi When i am trying to run the Export Script i am getting the Error Exception calling "ExportSearchConfiguration" with "1" argument(s): "The object is not associated with an object identity or the object identity is invalid." .Can you let me know if i am missing something ,
    – Anil
    Commented Oct 17, 2016 at 20:13
     Add managed properties to the Search Service Application.

     Add managed properties to the Search Service Application.

     File Name: Create-ManagedProperty.ps1
     Author   : Bart Kuppens
     Version  : 1.0

    .PARAMETER ConfigFile
     Specifies the location and name of the config file which contains the properties that need to be created.

    .PARAMETER SearchAppName
     Specifies the name of the Search Service Application.

     PS > .\Create-ManagedProperty.ps1 -ConfigFile "c:\temp\managedproperty.xml" -SearchAppName "Enterprise Search Service"
     [Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$false,HelpMessage="Specifies the URL of the Web Application.")] 

[Parameter(Position=1,Mandatory=$true,ValueFromPipeline=$false,HelpMessage="Specifies the name of the Search Service Application.")] 

if ( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )
   Write-Host "Loading SharePoint cmdlets..."
   Add-PsSnapin Microsoft.SharePoint.PowerShell

#get the XML file
if (!$ConfigFile)
   Write-Host "Could not find the configuration file specified. Aborting execution!" -ForegroundColor red    

Write-Host "Parsing file: " $file
[System.Xml.XmlDocument]$XmlDoc = [xml](Get-Content $file)

$searchapp = Get-SPEnterpriseSearchServiceApplication $SearchAppName

# Add Managed Properties
$PropertyNodeList = $XmlDoc.SearchConfiguration.ManagedProperties
foreach ($PropertyNode in $PropertyNodeList.ManagedProperty) 
   $SharePointProp = $PropertyNode.Name
   $SharePointPropType = $PropertyNode.Type
   $SharePointPropMapList = $PropertyNode.Map

   if ($mp = Get-SPEnterpriseSearchMetadataManagedProperty -SearchApplication $searchapp -Identity $SharePointProp -ea "silentlycontinue")
     Write-Debug -Message [$mp]
   New-SPEnterpriseSearchMetadataManagedProperty -SearchApplication $searchapp -Name $SharePointProp -Type $SharePointPropType
   $mp = Get-SPEnterpriseSearchMetadataManagedProperty -SearchApplication $searchapp -Identity $SharePointProp
   foreach ($SharePointPropMap in $SharePointPropMapList) 
      $SPMapCat = $SharePointPropMap.Category
      $SPMapName = $SharePointPropMap.InnerText
      $cat = Get-SPEnterpriseSearchMetadataCategory –SearchApplication $searchapp –Identity $SPMapCat
      $prop = Get-SPEnterpriseSearchMetadataCrawledProperty -SearchApplication $searchapp -Category $cat -Name $SPMapName
      New-SPEnterpriseSearchMetadataMapping -SearchApplication $searchapp -CrawledProperty $prop -ManagedProperty $mp

XML File Formata

        <Solutions SolutionSourceDir="">
        <!--WebApplication: Provide the destination web application where to deploy the solution-->
        <!-- - Use a * to deploy to all web applications-->
        <!-- - Leave empty if solution is a global solution-->
        <Solution SolutionName="" WebApplication="http://sp10/" />
                        <CrawledProperty Name="ows_mtes_ExerciseSeries" DataType="Text"/>
                        <CrawledProperty Name="ows_mtes_ExercisePhase" DataType="Text"/>
                        <CrawledProperty Name="ows_mtes_StaffFunction" DataType="Text"/>
                        <CrawledProperty Name="ows_mtes_DocumentType" DataType="Text"/>
                        <ManagedProperty Name="mtesExerciseSeries" DataType="1" OptimizedProperty="True" >
                            <Map Category="SharePoint">ows_mtes_ExerciseSeries</Map>
                        <ManagedProperty Name="mtesExercisePhase" DataType="1" >
                            <Map Category="SharePoint">ows_mtes_ExercisePhase</Map>
                        <ManagedProperty Name="mtesStaffFunction" DataType="1" >
                            <Map Category="SharePoint">ows_mtes_StaffFunction</Map>
                        <ManagedProperty Name="mtesDocumentType" DataType="1" >
                            <Map Category="SharePoint">ows_mtes_DocumentType</Map>

  • This is server side script, this is NOT CSOM.
    – James Love
    Commented Dec 15, 2016 at 16:19
  • Yes this is not for SharePoint Online! Commented Jan 18, 2017 at 21:49

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.