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 | |
You are using mixed versions of the CSOM library dlls. Make sure they are the same version 15 vs 16, etc.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When i try to run this script I get the following error when executing "$searchConfigurationPortability = New-Object Microsoft.SharePoint.Client.Search.Portability.SearchConfigurationPortability($clientContext)" :
New-Object : Cannot find an overload for "SearchConfigurationPortability" and the argument count: "1".
At D:\Install\CDMS_Release_1.2_20150421_084744\SetUpManagedProperties.ps1:33 char:35
Do you know what to do in this case?