Finding in-place records in SharePoint 2010 and SharePoint 2013 using PowerShell


Discovering in-place records.

Records management in SharePoint (2010 and 2013) is a great feature.  One of the solutions available is to declare a document a record ‘in place’ e.g. in the document library that it currently resides in.  Over the past few engagements with customers, I’ve found this to be the most common solution.

Something that I was recently asked to look at was to answer a question from a records manager. The question was ‘how do I identify how many in-place records have been declared, and by whom?’.

PowerShell is always my first answer 🙂

Below is a script that outputs (on screen) documents that are declared as records, when they were declared as records, and by whom. As with all scripts that you find on the interwebs, they haven’t been tested on your environment; so its up to you to ensure that they are before you use them in anger!

I'd also like to thank my colleague Herman Solberg for pointing me in the direction of the audit logs!

asnp *sharepoint* -ErrorAction SilentlyContinue

Clear-Host

$webApp = Get-SPWebApplication http://content.contoso.com

$siteColl = $webApp.Sites

foreach ($site in $siteColl)

{

       $webs = $site.AllWebs

       foreach ($web in $webs)

       {

             $lists = $web.Lists

             foreach ($list in $lists)

             {

                    if ($list.BaseTemplate -eq "DocumentLibrary")

                    {

                           if (($list.Title -ne "List Template Gallery") -and ($list.Title -ne "Reporting Templates") -and ($list.Title -ne "Form Templates") -and ($list.Title -ne "Customized Reports") -and ($list.Title -ne "Site Assets") -and ($list.Title -ne "Style Library"))

                           {           

                                 $auditQuery = New-Object -TypeName Microsoft.SharePoint.SPAuditQuery($site)   

                                 $items = $list.get_Items()

                                 foreach ($item in $items)

                                 {

                                        $IsRecord = [Microsoft.Office.RecordsManagement.RecordsRepository.Records]::IsRecord($item)

                                        if ($IsRecord)

                                        {

                                               $auditQuery.RestrictToListItem($item)

                                               $auditResults = $site.Audit.GetEntries($auditQuery)

                                               foreach ($entry in $auditResults)

                                               {

                                                     $userId = $entry.UserId           

                                                     $userEntry = $web.AllUsers | Where {$_.ID -eq $userId}

                                                     $userLogin = $userEntry.LoginName

                                               }

                                               $declaredDate = [Microsoft.Office.RecordsManagement.RecordsRepository.Records]::RecordDeclarationDate($item)

                                               Write-Host $declaredDate $item.Name $userLogin

                                        }

                                 }

                           }

                    }

             }

       }

       $site.Dispose()

}

For more information about records management in SharePoint; please read the following article:

https://technet.microsoft.com/en-us/library/cc261982.aspx

Cheers! @moss_sjeffery

 

Comments (0)

Skip to main content