Guest User

Untitled

a guest
Jan 30th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client") #| Out-Null
  2. [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime") #| Out-Null
  3. Add-Type -Path "c:Program FilesSharePoint Online Management ShellMicrosoft.Online.SharePoint.PowerShellMicrosoft.Online.SharePoint.Client.Tenant.dll"
  4. cls
  5.  
  6. $username = "login@domain.com"
  7. $password = ConvertTo-SecureString "" -AsPlainText -Force
  8.  
  9. $siteUrl = [string]::Format("https://company.sharepoint.com/sites/site1/")
  10. $cc = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
  11. $cc.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)
  12.  
  13. $list = $cc.Web.GetList("/sites/site1/Lists/List1")
  14. $cc.Load($list);
  15. $cc.ExecuteQuery();
  16.  
  17. $query = New-Object Microsoft.SharePoint.Client.CamlQuery
  18. $query.ViewXml = "<View><RowLimit>100</RowLimit></View>"
  19. $i = 1
  20. $y = 0
  21.  
  22. do
  23. {
  24. Write-Host "Round $i" -ForegroundColor DarkYellow
  25. $listItems = $list.GetItems($query);
  26. $cc.Load($listItems);
  27. $cc.ExecuteQuery();
  28. foreach($item in $listItems)
  29. {
  30. Write-Host "Updating item $($item.Id)" #"$($item.DisplayName)" -ForegroundColor Yellow
  31. # Update item here
  32. $item.Update()
  33. $y++
  34.  
  35. if($y -eq 10)
  36. {
  37. $cc.ExecuteQuery()
  38. $y=0
  39. }
  40. }
  41. $query.ListItemCollectionPosition = $listItems.ListItemCollectionPosition
  42. $i++
  43. }
  44. while ($query.ListItemCollectionPosition -ne $null)
Add Comment
Please, Sign In to add comment