Below script will be helpful to get the SharePoint List Item with given Item ID.
Inputs:
- 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["ID"]
$item["Title"] = "Using Powershell"
$item.Update()
#Function comes here #
}
Add the below line inside above foreach to delete the List Item,
$item.Delete()
No comments:
Post a Comment