Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Delete items from list using powershell

$
0
0

The script I have right now, deletes all the items in the list. But I want to change the script so it only deletes specific records.

For example, I want to do a loop and if the businessid (column) value is equal to 9999, delete the record.

below is a script that i have to delete all items in the list (but this isnt what I want to do )

    Add-PSSnapin Microsoft.SharePoint.PowerShell
    $web = get-spweb "https://staging/training/"
    $List = $web.lists["ItemsList"]
    $Items = $List.GetItems()
    $Items | ForEach-Object{
     $List.GetItemById($_.Id).Delete()
    }
    $List.Update()


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>