Created
December 3, 2013 23:55
-
-
Save chrisobriensp/7779915 to your computer and use it in GitHub Desktop.
PS + CSOM to import search schema XML (e.g. managed property definitions)..
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
. .\TopOfScript.ps1 | |
# need some extra types bringing in for this script.. | |
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Search.dll" | |
# TODO: replace this path with yours.. | |
$pathToSearchSchemaXmlFile = "C:\COB\Cloud\PS_CSOM\XML\COB_TenantSearchConfiguration.xml" | |
# we can work with search config at the tenancy or site collection level: | |
#$configScope = "SPSiteSubscription" | |
$configScope = "SPSite" | |
$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) | |
$clientContext.ExecuteQuery() | |
Write-Host "Search configuration imported" -ForegroundColor Green | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You are using mixed versions of the CSOM library dlls. Make sure they are the same version 15 vs 16, etc.