If I run each line individually, it works. But If I try to run the script with the for each loop, I get: Exception calling "Update" with "0" argument(s): "Value does not fall within the expected range."
Code:
$listItems = $list.GetItems($query)
$query.ListItemCollectionPosition = $listItems.ListItemCollectionPosition
foreach($item in $listItems)
{
# DeleteItems
# UpdateItems
# CancelWorkflows
$reason = $item["Reason"] + " -- This Exception was open more than 30 days and will be closed by the administrator"
$item["Reason"] = $reason
$item.Update()
Write-Host "Added Reason Code - $($item.ID)"
$reason = $null
$count = $count+1
}
Do I need to update a different way? When I break and check the variables, $item["Reason"] is empty so it makes sense that I have 0 arguments.
More Info: There are some columns that are required. There is a chance one of them may be empty and so the item can't be updated unless that field has a value. Can I force an update to an item even if a required field is blank?
$reason
being empty is not what's mentionned by the error message, that simply states the error occurs onUpdate()
(aka "Update" with "0" argument(s)). So the truth is elsewhere...