It takes forever to update items using foreach loop. Any other idea?
if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null) {
Add-PSSnapin Microsoft.SharePoint.PowerShell
}
$web=get-SPWeb "http://inside.nov.com/sites/sales/Apps"
$list=$web.Lists["Norton Security"]
$CAML = '<Where>
<Or>
<IsNull>
<FieldRef Name="RanUpdate" />
</IsNull>
<Eq>
<FieldRef Name="RanUpdate" />
<Value Type="Boolean">False</Value>
</Eq>
</Or>
</Where>'
$query = new-object Microsoft.SharePoint.SPQuery
$query.ViewAttributes = "Scope='Recursive'"
#$query.RowLimit = 10
$query.Query = $CAML
$listitems = $list.GetItems($query)
$count = $listitems.count
write-host $count
# End script
#Break
if ($count -ge 1)
{
foreach($item in $listitems)
{
$item["Year"] = "2010"
$item["RanUpdate"] = $true
$item.SystemUpdate()
}
}
$web.dispose()