I have a short script which is going to be part of a larger one but I can't get it to work. It works on every other list I've tried running it against but not this one in particular. The $myList.ItemCount
returns the correct number of list items as 4987 but the $items.Count returns 0 and the foreach
loop returns no results. Anyone ever deal with this issue? I'm sure it has something to do with the list itself as I made a template of it, copied it to another site, ran the exact same script with the updated url and it worked.
Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
$myWeb = Get-SPWeb "https://mysiteurl.org"
$myList = $myWeb.Lists["My List"]
$myView = $myList.Views["All Items"]
$items = $myList.GetItems($myView)
Write-Output $myList.ItemCount
write-output $items.Count
foreach($item in $items)
{
Write-Output $item
}
Any help would be greatly appreciated.