Hello Im getting this error when executing this. Can you please help me?
foreach($item in $items)
{
$created = $item["Created"]
if ($created -lt $days)
{
Write-Host "Title - " $item["Title"] "Created - " $item["Created"]
$test = $item["ID"]
write-host $test
$item["ID"].DeleteObject()
#$item[].DeleteObject()
}
}
$context.ExecuteQuery()
Method invocation failed because [System.Int32] does not contain a method named 'DeleteObject'. At F:\JoshScript\deletebydate.ps1:46 char:2 + $item["ID"].DeleteObject() + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : MethodNotFound
$item.DeleteObject()
? could you add the line where you create$items
? what type/object is it? – Guenther Schmitz