Guest User

Untitled

a guest
Jan 2nd, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. $SiteURL = "https://domain.sharepoint.com"
  2.  
  3. Write-Host "Loading CSOM libraries" -foregroundcolor black -backgroundcolor yellow
  4.  
  5. Add-Type -Path "c:Program FilesCommon Filesmicrosoft sharedWeb Server Extensions15ISAPIMicrosoft.SharePoint.Client.dll"
  6.  
  7. Add-Type -Path "c:Program FilesCommon Filesmicrosoft sharedWeb Server Extensions15ISAPIMicrosoft.SharePoint.Client.Runtime.dll"
  8.  
  9. Write-Host "Lib. successfully loaded !" -foregroundcolor black -backgroundcolor Green
  10.  
  11. $scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
  12.  
  13. $User = Read-Host -Prompt "username"
  14.  
  15. $password = Read-Host -Prompt "Enter password" -AsSecureString
  16.  
  17. Write-Host "Trying to reach $SiteURL // Handling ClientContext..." -foregroundcolor black -backgroundcolor yellow
  18.  
  19. $Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
  20.  
  21. $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($User, $password)
  22.  
  23. $Context.Credentials = $credentials
  24.  
  25. $context.RequestTimeOut = 5000 * 60 * 10;
  26.  
  27. $web = $context.Web
  28.  
  29. $site = $context.Site
  30.  
  31. $context.Load($web)
  32.  
  33. $context.Load($site)
  34.  
  35. try
  36.  
  37. {
  38.  
  39. $context.ExecuteQuery()
  40. Write-Host "Connected !" -foregroundcolor black -backgroundcolor Green
  41. }
  42. catch
  43. {
  44. Write-Host "Impossible to reach $SiteURL : bad password ?" -foregroundcolor black -backgroundcolor Red
  45. return
  46. }
  47. $list = $web.Lists.GetByTitle("Custom List");
  48.  
  49. $fields = $list.Fields;
  50.  
  51. $context.Load($web)
  52.  
  53. $context.Load($site)
  54.  
  55. $context.Load($list)
  56.  
  57. $context.Load($fields)
  58.  
  59. $context.ExecuteQuery()
  60.  
  61. $fields | select SchemaXML | Export-Csv -path "d:schema.csv";`
Add Comment
Please, Sign In to add comment