NicksonKoh
asked on
Delete all records in a Picture Library
Hi,
I wrote a simple powershell script to delete all the records in a SharePoint 2007 Picture Library.
But I am getting error "An error occurred while enumerating through a collection: Collection was modified; enumeration operation may not exec
ute.."
Can advise where I am wrong?
I wrote a simple powershell script to delete all the records in a SharePoint 2007 Picture Library.
$sc = New-Object Microsoft.SharePoint.SPSite($webURL)
$web = $sc.OpenWeb()
$srcList = $web.Lists[$srcListName]
## Loop through the items in the Document Library
$srcItemCnt = 0
foreach($srcItem in $srcList.items) {
Write-Host $srcItem["ID"]
$srcItem.Delete()
}
$web.Dispose()
$sc.Dispose()
But I am getting error "An error occurred while enumerating through a collection: Collection was modified; enumeration operation may not exec
ute.."
Can advise where I am wrong?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.