Check whether the item is in hold in SharePoint 2010 using powershell

In Shared Documents I have a document "New”, here I am going to check whether the item is in hold or not using powershell.

Go to Start => All Programs => Microsoft SharePoint 2010 Products => SharePoint 2010 Management Shell => Run as an administrator. => Run the following script.

$site = get-SPSite("
http://servername:22222/sites/Test/")
$web = $site.RootWeb
$list = $web.Lists["Shared Documents"]
foreach ($item in $list.Items)
{
 if ($item.DisplayName.ToString() -eq "New")
 {
   if([Microsoft.Office.RecordsManagement.Holds.Hold]::IsItemOnHold($item))
   {
      write-host -f green $item.DisplayName "is on hold"
   }
 }
}

Ebook Download
View all
Learn
View all