function Update-SPOListItem {
param (
[Parameter(Mandatory=$true,Position=1)] [string]$Username,
[Parameter(Mandatory=$true,Position=2)] [string]$Url,
[Parameter(Mandatory=$true,Position=3)] [string]$AdminPassword,
[Parameter(Mandatory=$true,Position=4)] [string]$ListTitle
)
$password = ConvertTo-SecureString -string $AdminPassword -AsPlainText -Force
$ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url)
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password)
$ctx.Load($ctx.Web.Lists)
$ctx.Load($ctx.Web)
$ctx.Load($ctx.Web.Webs)
$ctx.ExecuteQuery()
$ll=$ctx.Web.Lists.GetByTitle($ListTitle)
$ctx.Load($ll)
$ctx.ExecuteQuery()
$spqQuery = New-Object Microsoft.SharePoint.Client.CamlQuery
$spqQuery.ViewXml = "@
<View>
<Query>
<ViewFields>
<FieldRef Name='ID'></FieldRef>
<FieldRef Name='Column2'></FieldRef>
</ViewFields>
<OrderBy><FieldRef Name='ID' Ascending='TRUE'/></OrderBy>
</Query>
<RowLimit>5000</RowLimit>
</View>"
$itemki=$ll.GetItems($spqQuery)
$ctx.Load($itemki)
$ctx.ExecuteQuery()
$count=$itemki.Count
Write-Host $count
$ctx.RequestTimeOut = 5000*10000
$i =1
ForEach($Item in $itemki)
{
Write-Host "Updating ID : " + $Item["ID"]
$Item["Column2"] = $Item["ID"]
$Item.Update()
$ctx.ExecuteQuery()
}
}
# Paths to SDK. Please verify location on your computer.
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
#remove less than and greater than symbol in below command
Update-SPOListItem -Username <UserName> -Url <SiteCollection URL> -AdminPassword <Password> -ListTitle <ListName>