SHARE
TWEET

Untitled

a guest Oct 3rd, 2017 48 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.  
  4. $xmlFilePath = "C:\Users\elonguir\Documents\Script-SiteColumns.xml"
  5.  
  6. $SiteCollURL = ""
  7. $UserName = ""
  8. $Password = ""
  9. $SecurePassword= ConvertTo-SecureString $Password –asplaintext –force
  10.  
  11. #Bind to site collection
  12. $Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteCollURL)
  13. $Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName,$SecurePassword)
  14. $Context.Credentials = $Creds
  15. $Web = $Context.Web
  16.  
  17. #Create Export Files
  18. New-Item $xmlFilePath -type file -force
  19.  
  20. #Export Site Columns to XML file
  21. Add-Content $xmlFilePath "<?xml version=`"1.0`" encoding=`"utf-8`"?>"
  22. Add-Content $xmlFilePath "`n<Fields>"
  23. $Context.Load($Web.Fields)
  24. $Context.ExecuteQuery()
  25. $Web.Fields | ForEach-Object {
  26.     $Context.Load($_)
  27.     $Context.ExecuteQuery()
  28.     if ($_.Group -eq "Enterprise Keywords Group") {
  29.         $Context.Load($_)
  30.         $Context.ExecuteQuery()
  31.         Add-Content $xmlFilePath $_.SchemaXml
  32.     }
  33. }
  34. Add-Content $xmlFilePath "</Fields>"
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
 
Top