Using SharePoint 2016
I am trying to update lookup column in a document library via CSV using below PowerShell:
it only updating few and giving below error on rest of the items. The CSV and Doc Library both have 10K+ records.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Read the CSV file
$CSVData = Import-CSV -path "C:\data.csv"
#Get the Web
$web = Get-SPWeb -identity "Site collection URL"
#Get the Target List
$List = $web.Lists["Library Name"]
#Iterate through each Row in the CSV
foreach ($Row in $CSVData)
{
#Get the List Item matching "EmployeeID" field in the CSV
$Item = $List.Items | Where-Object { $_["EmpID"] -eq $Row.EmployeeID }
if($item -ne $null)
{
#Update List Item - Internal Name!
$item["Tecode"] =[int]$row.ID
#$item.Update()
$item.SystemUpdate()
Write-Host "Updated:"$row.EmployeeID -ForegroundColor Green
}
else
{
write-host "No matching Item Found for:"$row.EmployeeID -f Red
}
}