0

I'm using SPMeta2 CSOM code to create and populate lists,contentTypes and columns to my onpremm sharepoint site, but i cannot find a way to create Managed Properties.

Is there any way to do it, i have googled and just found Powershell and SSOM code that can do it.

user2269364
  • 67
  • 1
  • 9

1 Answers1

0

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"

     try
        {

         var User = "userName";
         var Password = "password";
         var SiteURL = "http://siteUrl/";
         var domainName = "domain name";
        var xDocument = XDocument.Load(@"C:\MyFile11.xml");        
        string xml = xDocument.ToString();


        var context = new Microsoft.SharePoint.Client.ClientContext(SiteURL);
        context.Credentials =   new NetworkCredential(User, GetSecurePassword(Password),domainName);


        var searchConfigurationPortability = new Microsoft.SharePoint.Client.Search.Portability.SearchConfigurationPortability(context);
        var Search = new Microsoft.SharePoint.Client.Search.Portability.SearchConfigurationPortability(context);
        var Owner = new Microsoft.SharePoint.Client.Search.Administration.SearchObjectOwner(context, SearchObjectLevel.Ssa);

        //Export search conf schema
        var SearchConfig = Search.ExportSearchConfiguration(Owner);
        context.ExecuteQuery();

        XmlDocument xdoc = new XmlDocument();
        xdoc.LoadXml(SearchConfig.Value);
        xdoc.Save("myfilenameSSA.xml");

        // import search conf schema
        Search.ImportSearchConfiguration(Owner, xml);
        context.ExecuteQuery();

        }           
        catch (Exception ex)
        {
            Console.WriteLine(ex.ToString());
        }
    }
user2269364
  • 67
  • 1
  • 9