I am trying to update a SharePoint list, because of its size and to make things faster I want to use a DataTable.
$webURL = "http://test/test"
$listName = "Test List"
$web = Get-SPWeb $webURL
$list = $web.Lists[$listName]
$items = $list.items.GetDataTable() | select LinkTitle, Failure_x0020_Step
foreach($item in $items)
{
if(($item.LinkTitle -eq "PC111"))
{
$item.Failure_x0020_Step = "Failure Test"
$item.Update()
}
else {}
}
I get this error when running the script:
Method invocation failed because [System.Data.DataRow] doesn't contain a method named 'Update'. + CategoryInfo : InvalidOperation: (Update:String) [], RuntimeException + FullyQualifiedErrorId : MethodNotFound
I do have it working without the DataTable (changes below), but would prefer the DataTable.
$items = $list.items
if(($item["Computer"] -eq "PC111"))
$item["Failure Step"] = "Failure Test"
BeginEdit()
andEndEdit()
methods, that I think you need to use instead ofUpdate()
. Unfortunately, the sharepoint environment I have is currently broken, so I can't test to see if that'll behave better. – Hunter Eidson