SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?


share|improve this question

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) 
share|improve this answer
ok. now, should I just save it as .ps and then run it from PS?? – hello B Mar 6 '12 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... – Wictor Wilen MCA MCM MVP Mar 7 '12 at 14:32
OP should really start to accept answers - especially such obviously correct ones. – curmudgeon Nov 22 '12 at 10:16

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("") # 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)
share|improve this answer
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – Stuart Pegg Aug 21 '12 at 14:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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