Friday, August 9, 2013

Get or Delete SharePoint List Item using Powershell

Below script will be helpful to get the SharePoint List Item with given Item ID.

  • Site URL
  • List Name
  • Item ID

if ((Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null)
Add-PSSnapin Microsoft.SharePoint.PowerShell
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | Out-null
$web = Get-SPWeb http://sitename:portnumber/
$listName = "Discussion"
$list = $web.Lists[$listName]
$items = $list.Items | Where {$_["ID"] -eq 741}
foreach($item in $items)
$item["Title"] = "Using Powershell"
#Function comes here #

Add the below line inside above foreach to delete the List Item,

Related Posts Plugin for WordPress, Blogger...