Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $SiteURL = "https://domain.sharepoint.com"
- Write-Host "Loading CSOM libraries" -foregroundcolor black -backgroundcolor yellow
- Add-Type -Path "c:Program FilesCommon Filesmicrosoft sharedWeb Server Extensions15ISAPIMicrosoft.SharePoint.Client.dll"
- Add-Type -Path "c:Program FilesCommon Filesmicrosoft sharedWeb Server Extensions15ISAPIMicrosoft.SharePoint.Client.Runtime.dll"
- Write-Host "Lib. successfully loaded !" -foregroundcolor black -backgroundcolor Green
- $scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
- $User = Read-Host -Prompt "username"
- $password = Read-Host -Prompt "Enter password" -AsSecureString
- Write-Host "Trying to reach $SiteURL // Handling ClientContext..." -foregroundcolor black -backgroundcolor yellow
- $Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
- $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($User, $password)
- $Context.Credentials = $credentials
- $context.RequestTimeOut = 5000 * 60 * 10;
- $web = $context.Web
- $site = $context.Site
- $context.Load($web)
- $context.Load($site)
- try
- {
- $context.ExecuteQuery()
- Write-Host "Connected !" -foregroundcolor black -backgroundcolor Green
- }
- catch
- {
- Write-Host "Impossible to reach $SiteURL : bad password ?" -foregroundcolor black -backgroundcolor Red
- return
- }
- $list = $web.Lists.GetByTitle("Custom List");
- $fields = $list.Fields;
- $context.Load($web)
- $context.Load($site)
- $context.Load($list)
- $context.Load($fields)
- $context.ExecuteQuery()
- $fields | select SchemaXML | Export-Csv -path "d:schema.csv";`
Add Comment
Please, Sign In to add comment