SHARE
TWEET

Untitled

a guest Oct 3rd, 2017 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
  2. Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
  3. Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Taxonomy.dll"
  4.  
  5. $xmlFilePath = "C:\Users\elonguir\Documents\Script-SiteColumns.xml"
  6.  
  7. $SiteCollURL = ""
  8. $UserName = ""
  9. $Password = ""
  10. $SecurePassword= ConvertTo-SecureString $Password –asplaintext –force
  11.  
  12. #Bind to site collection
  13. $clientContext = New-Object Microsoft.SharePoint.Client.ClientContext($SiteCollURL)
  14. $Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName,$SecurePassword)
  15. $clientContext.Credentials = $Creds
  16. $Web = $clientContext.Web
  17.  
  18. #get the respective web  
  19. $Site = $clientContext.Site  
  20. $Web = $Site.RootWeb  
  21.  
  22. #Get all fields collection  
  23. $fields = $Web.Fields  
  24.  
  25. $clientContext.Load($Web)  
  26. $clientContext.Load($fields)  
  27. $lists = $Web.Lists
  28. $list = $lists.GetByTitle("TaxonomyHiddenList")  
  29. $clientContext.Load($list)
  30. $clientContext.ExecuteQuery()
  31.  
  32. #$field = $clientContext.Site.RootWeb.Lists.GetByTitle("Documentos").Fields.GetByInternalNameOrTitle("TaxKeyword")
  33. $field = $clientContext.Site.RootWeb.Fields.GetByInternalNameOrTitle("TaxKeyword")
  34. $taxField = [Microsoft.SharePoint.Client.ClientContext].GetMethod("CastTo").MakeGenericMethod([Microsoft.SharePoint.Client.Taxonomy.TaxonomyField]).Invoke($clientContext, $field)  
  35.  
  36. $clientContext.Load($taxField);
  37. $clientContext.ExecuteQuery();
  38. <#$taxField.Open = $true;
  39. $taxField.IsKeyword = $true;
  40. $taxField.CreateValuesInEditForm = $true;#>
  41. #$taxField.SchemaXml = $taxField.SchemaXml.Replace($taxField.LookupList.ToString(), $list.ID.ToString("B"))
  42. $taxField.Update();
  43. $clientContext.Load($taxField)  
  44. $clientContext.ExecuteQuery();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top