SharePoint 2013/2016: Deleting All List Item Using Powerhshell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$web = get-spweb "SiteCollectionURL"; | |
$list = $web.lists | where {$_.title -eq "<You List Name>"} | |
Write-host "List $($list.title) has $($list.items.count) entries" | |
write-host "This will delete data, type YES to continue" | |
$retval = read-host | |
if ($retval -ne "YES") | |
{ | |
write-host "exiting - you did not type yes" -foregroundcolor green | |
exit | |
} | |
write-host "continuing" | |
$items = $list.items | |
foreach ($item in $items) | |
{ | |
Write-host " Say Goodbye to $($item.id)" -foregroundcolor red | |
$list.getitembyid($Item.id).Delete() | |
} |
Comments
Post a Comment