0

I am running a simple code in PowerShell but i get the error Cannot index into a null array. I am new in PowerShell, but basically i am traying to delete but first view all records from a big list with specific date. Please Help

 $web= Get-SPWeb "http://intranet****"

 $listname= "Guideline"

 $list= $web.Lists[$listname]

 $items= $list.Items | where {$_["Created"] -eq '2/9/2018'}

 foreach($item in $items)
{

 Write-Host created : $Item["created"]

}

1 Answer 1

0

You can update your scripts as shown below and try again:

  1. Use -gt and -lt for datetime column instead of -eq
  2. Change $Item["created"] to $item["Created"], capital "C"
$listname= "Guideline"

 $list= $web.Lists[$listname]

 $items= $list.Items | where {$_["Created"] -gt '2/9/2018' -and $_["Created"] -lt '3/9/2018'}

 $items.Count

 foreach($item in $items)
{

 Write-Host created : $item["Created"]

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.