Does anybody know if there's some way to delete items from an SPList using PowerShell scripting?

If is this possible, has anybody any good tutorial?


2 Answers 2


Since you can access the object model it's pretty straight forward

asnp microsoft.sharepoint.powershell
$web = Get-SPWeb http://thesite/
$list = $web.Lists["NameOfList"]
$item = $list.GetItemById(1) 
  • ok. now, should I just save it as .ps and then run it from PS??
    – hello B
    Commented Mar 6, 2012 at 20:04
  • You just open a new powershell session and write the code...and yes, you could make it into a .ps1 script file if you need... Commented Mar 7, 2012 at 14:32

Here's the example.

Quote from link:

Delete Item -

The example below will count the items and loop down, read the name of the item, and if the item contains a 3, then it will delete that item.

$site = new-object Microsoft.SharePoint.SPSite("http://test.tomdaly.com") # is a legit url
$relweburl = "/Docs"
$web = $site.openweb($relweburl)
$list=$web.Lists["testList"] $listItems = $list.Items
$listItemsTotal = $listItems.Count

for ($x=$listItemsTotal-1;$x -ge 0; $x--)
        Write-Host("DELETED: " + $listItems[$x].name)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.