Posts

Showing posts from April, 2021

Sharepoint Powershell - Delete all Items from a List on the Basis of Status

  This post is to explain the process of deleting all items from a list on the basis of the status (e.g. status= completed) using PowerShell script in Sharepoint. To use the below script add your list/library name e.g. $docName=”<your list/library name>” and your SharePoint site/web address e.g.  $web = Get-SPWeb <your site/web address> Script: Add-PSSnapin  Microsoft.SharePoint.PowerShell  $web   =   Get-SPWeb  <your site/web Url> $docName = " <list/library display name> " $list   =   $web.lists   |   where   {$ _ .title   -eq   $docName} for ($x = $list.ItemCount - 1 ;$x   -ge   0 ;   $x -- ) {           $item = $list.Items[$x];           if ($item[ " Status " ]   -eq   " COMPLETED " )      {       Write-Host   " Deleting item id "   $item.ID       $item.Delete();                       } } $list.Update();