I need to delete list from a site collection using power shell commands. Can anyone help me with the code.
[Actual requirement : Delete all list which starts with "xyz"]
Here it is:
$startsWith = "ABC"
$site = Get-SPSite http://mycoolsite
$webs = $site.AllWebs
foreach ($web in $webs) {
$lists = $web.Lists
for ($index = 0; $index -lt $lists.Count; $index++) {
if ($lists[$index].Title.StartsWith($startsWith)) {
$lists[$index].Delete()
}
}
$web.Dispose()
}
$site.Dispose()
for ($index = $lists.Count - 1; $index -ge 0; $index--) {