Delete List Items Powershell Script


$url = “http://portal.lab.local/”
$listName = “Test”

Write-Host “Starting…”

$site = Get-SPSite $url
Write-Host “Site Guid is:” $site.ID
$web = $site.OpenWeb()
$list = $web.Lists[$listName]

Write-Host “List Guid is:” $list.ID “List Title is: ” $list.Title

$listItems = $list.GetItems()
$itemCount = $listItems.Count

Write-Host “List Item Count is:” $itemCount

$i = $itemCount -1
while ($i -gt -1){Write-Host $i $listItems.Delete($i); $i–}

$web.RecycleBin.DeleteAll()

Write-Host “Done…”

Advertisements
Tagged with: ,
Posted in 2010, PowerShell
One comment on “Delete List Items Powershell Script

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Antek Group Blog
Categories
%d bloggers like this: