Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client") #| Out-Null
- [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime") #| Out-Null
- Add-Type -Path "c:Program FilesSharePoint Online Management ShellMicrosoft.Online.SharePoint.PowerShellMicrosoft.Online.SharePoint.Client.Tenant.dll"
- cls
- $username = "login@domain.com"
- $password = ConvertTo-SecureString "" -AsPlainText -Force
- $siteUrl = [string]::Format("https://company.sharepoint.com/sites/site1/")
- $cc = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
- $cc.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)
- $list = $cc.Web.GetList("/sites/site1/Lists/List1")
- $cc.Load($list);
- $cc.ExecuteQuery();
- $query = New-Object Microsoft.SharePoint.Client.CamlQuery
- $query.ViewXml = "<View><RowLimit>100</RowLimit></View>"
- $i = 1
- $y = 0
- do
- {
- Write-Host "Round $i" -ForegroundColor DarkYellow
- $listItems = $list.GetItems($query);
- $cc.Load($listItems);
- $cc.ExecuteQuery();
- foreach($item in $listItems)
- {
- Write-Host "Updating item $($item.Id)" #"$($item.DisplayName)" -ForegroundColor Yellow
- # Update item here
- $item.Update()
- $y++
- if($y -eq 10)
- {
- $cc.ExecuteQuery()
- $y=0
- }
- }
- $query.ListItemCollectionPosition = $listItems.ListItemCollectionPosition
- $i++
- }
- while ($query.ListItemCollectionPosition -ne $null)
Add Comment
Please, Sign In to add comment