3

I want to track down files in a site collection that have not been used or accessed for X years. I found out that you can delete old documents by SharePoint Auditing, but what I want to do is list not only documents, but also lists, libraries and even sub-sites that have not been used/accessed. Is this possible?

Thanks in advance.

2 Answers 2

2

What is pretty easy, is to get the "Modified" date of a site, list or document. But for last access date, I don't know of any way to get this information.

Propably you could use the logging DB (WSS_Logging) of SharePoint:

https://www.codeproject.com/kb/sharepoint/sploggingdatabase.aspx

to run Reporting on that table is supported. Maybe you can find information there.

Edit: You could also have I look here, which talks about the same suggestion I just made:

I cannot think of a PowerShell Script that will get the last access date for a site. Since all usage data is in the RequestUsage view of the WSS_Logging database and query this database is supported, you can create a pivot table with Excel 2010 PowerPivot or use SQL Analysis Service to build the report. Additionally, Varun has blogged about a solution for MOSS 2007, hopefully it could help in SP 2010 scenario. http://blogs.msdn.com/b/varun_malhotra/archive/2010/05/12/moss-2007-get-last-accessed-date-for-a-site.aspx

https://social.technet.microsoft.com/Forums/en-US/966d6169-4dd3-4da3-9194-105307622474/getting-last-access-date-via-powershell-in-sp2010?forum=sharepointadminprevious

2
  • Thanks Sebastian. Would you know if the WSS_Logging keeps track of items/documents too? The article about it states it does for page requests, but I don't know if viewing a item/document is considered a page request.
    – ranbo
    Commented Jan 18, 2017 at 11:27
  • This article also states that by default this database only stores data for a maximum of 14 days before the current date. I'll check this in my database and edit here later.
    – ranbo
    Commented Jan 18, 2017 at 13:54
0

Since we didn't have audit active, I had to go with the last modification date. I did that using a powershell script to go trough everything and save the results on a CSV file. Here is the script:

  function Get-DocInventory([string]$siteUrl) 
{ 
    $site = New-Object Microsoft.SharePoint.SPSite $siteUrl #gets site collection       # looping trough webs       foreach ($web in $site.AllWebs) 
    { 
        # looping trough lists          foreach ($list in $web.Lists) 
        { 
            # removing lists that are hidden, master page/list template/theme/web part galleries e style libraries
            if( $List.Hidden -eq $false -and $list.Title -ne "Style Library" -and $list.Title -ne "Master Page Gallery" -and $list.Title -ne "List Template Gallery" -and $list.Title -ne "Theme Gallery" -and $list.Title -ne "Web Part Gallery")
                {                       
                    # looping trough items
                    foreach ($item in $list.Items) 
                    { 
                    # the info I needed                         $data = @{ 
                            "Site" = $site.Url 
                            "Web" = $web.Url 
                            "List" = $list.Title 
                            "ID" = $item.ID 
                            "URL" = $item.Url 
                            "Title" = $item.Title 
                            "Created" = $item["Created"] 
                            "Modified" = $item["Modified"] 
                                 } 
                        # cria um objeto com as informacoes
                    } 
                }                       
        } 
         $data = @{
            "Site" = $site.Url 
            "Web" = $web.Url 
            "List" = "n/a" 
            "ID" = $web.ID 
            "URL" = $web.Url 
            "Title" = $web.Title 
            "Created" = $web.Created 
            "Modified" = $web.LastItemModifiedDate 
        }
            New-Object PSObject -Property $data | Select "Site", "Web", "List", "ID", "URL", "Title", "Created", "Modified"
            $web.Dispose(); 
    } 
        $site.Dispose()
}
 # command 
Get-DocInventory "http://yoursite" | Export-Csv -NoTypeInformation -Path "c:\results.csv"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.