locked
SharePoint 2010 - Site Collection - Last Accessed Date RRS feed

  • Question

  • Hi All,

    I would like to run a simple report that lists Sites that have not been accessed in the last 6 months.

    I will then use this data to contact Site Owners asking whether they intend on using the site so we can delete and prepare for a  SharePoint 2013 migration.

    Does anyone know of a quick solution to this problem? 

    Thanks,

    Tailz123

    Monday, February 29, 2016 3:53 PM

Answers

  • There are a few different ways to accomplish this.  Here are a couple that immediately come to mind

    1. Review and analyze IIS logs.  Get Log Parser 2.2 to parse through the logs and extract the information you need: URL and Date.
    2. Use the website's LastitemModifiedDate.  Here's a good source of information on this to get you started: Site Activity and LastItemModifiedDate \ LastContentModifiedDate.  This reference is for 2010 but not to worry: the property names and objects haven't changed.  Use this property in a set of PowerShell loops to pull this data item from all webs in the site collection and all site collections in the web application.
    • Proposed as answer by croute1 Monday, February 29, 2016 9:58 PM
    • Marked as answer by Sara Fan Tuesday, March 8, 2016 1:21 AM
    Monday, February 29, 2016 5:43 PM
  • The last access data can only be accessed through IISLogs but LastItemModified and Last Security Modified are also valuable.  Use the script below to extract for all site collections.

    Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue
    function Get-SPSiteLastAccessInfo
    {
        Param
        (
            # Param1 help description
            [Parameter(Mandatory=$true,Position=0)]
            [boolean]$IncludePersonalSites,
            [Parameter(Mandatory=$true,Position=1)]
            [string]$OutputPath
        )
    
    Start-SPAssignment -Global
    
    $Sites = @();
    
    $WebApps= Get-SPWebApplication
    $upm =  New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager([Microsoft.Office.Server.ServerContext]::Default)
    $MySiteWebApp = Get-SPWebApplication $upm.MySiteHostUrl
    foreach($webApp in $WebApps)
    {
        if($webApp.Url -eq $MySiteWebApp.Url -and $IncludePersonalSites -eq $false)
        {
            Write-Host "Personal Site"
            
        }
        else
        {
            Write-Host $WebApp.Url
            foreach($SiteCollection in $webApp.Sites)
            {
                $Site = Get-SPSite $SiteCollection.Url
                Write-Host "." -ForegroundColor Green -NoNewline
            
                $aSite = New-Object PSObject
                Add-Member -input $aSite noteproperty 'Site' $Site.Url
                Add-Member -input $aSite NoteProperty 'LastContentModifiedDate' $Site.RootWeb.LastItemModifiedDate
                Add-Member -input $aSite noteproperty 'LastSecurityModifiedDate' $Site.LastSecurityModifiedDate
                $Sites += $aSite
                $Site.Dispose()
            }
        }
    }
    
    Stop-SPAssignment -Global
    $Sites | Out-GridView
    
    $Sites | Export-Csv $OutputPath -NoTypeInformation
    Write-Host "Output Written in $OutputPath" -ForegroundColor Green
    
    }
    
    #Usage
    Get-SPSiteLastAccessInfo -IncludePersonalSites $true -OutputPath "C:\LastAccess1.txt"
    #Or
    Get-SPSiteLastAccessInfo -IncludePersonalSites $false -OutputPath "C:\LastAccess1.txt"


    Jerry Yasir - Office Server & Services MVP/MCT Hewlett Packard Enterprise - If this reply helped you resolve your issue, please propose as answer. It may help other community members. Thanks!

    • Proposed as answer by Victoria Xia Friday, March 4, 2016 1:56 PM
    • Marked as answer by Sara Fan Tuesday, March 8, 2016 1:21 AM
    Monday, February 29, 2016 7:11 PM

All replies

  • There are a few different ways to accomplish this.  Here are a couple that immediately come to mind

    1. Review and analyze IIS logs.  Get Log Parser 2.2 to parse through the logs and extract the information you need: URL and Date.
    2. Use the website's LastitemModifiedDate.  Here's a good source of information on this to get you started: Site Activity and LastItemModifiedDate \ LastContentModifiedDate.  This reference is for 2010 but not to worry: the property names and objects haven't changed.  Use this property in a set of PowerShell loops to pull this data item from all webs in the site collection and all site collections in the web application.
    • Proposed as answer by croute1 Monday, February 29, 2016 9:58 PM
    • Marked as answer by Sara Fan Tuesday, March 8, 2016 1:21 AM
    Monday, February 29, 2016 5:43 PM
  • The last access data can only be accessed through IISLogs but LastItemModified and Last Security Modified are also valuable.  Use the script below to extract for all site collections.

    Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue
    function Get-SPSiteLastAccessInfo
    {
        Param
        (
            # Param1 help description
            [Parameter(Mandatory=$true,Position=0)]
            [boolean]$IncludePersonalSites,
            [Parameter(Mandatory=$true,Position=1)]
            [string]$OutputPath
        )
    
    Start-SPAssignment -Global
    
    $Sites = @();
    
    $WebApps= Get-SPWebApplication
    $upm =  New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager([Microsoft.Office.Server.ServerContext]::Default)
    $MySiteWebApp = Get-SPWebApplication $upm.MySiteHostUrl
    foreach($webApp in $WebApps)
    {
        if($webApp.Url -eq $MySiteWebApp.Url -and $IncludePersonalSites -eq $false)
        {
            Write-Host "Personal Site"
            
        }
        else
        {
            Write-Host $WebApp.Url
            foreach($SiteCollection in $webApp.Sites)
            {
                $Site = Get-SPSite $SiteCollection.Url
                Write-Host "." -ForegroundColor Green -NoNewline
            
                $aSite = New-Object PSObject
                Add-Member -input $aSite noteproperty 'Site' $Site.Url
                Add-Member -input $aSite NoteProperty 'LastContentModifiedDate' $Site.RootWeb.LastItemModifiedDate
                Add-Member -input $aSite noteproperty 'LastSecurityModifiedDate' $Site.LastSecurityModifiedDate
                $Sites += $aSite
                $Site.Dispose()
            }
        }
    }
    
    Stop-SPAssignment -Global
    $Sites | Out-GridView
    
    $Sites | Export-Csv $OutputPath -NoTypeInformation
    Write-Host "Output Written in $OutputPath" -ForegroundColor Green
    
    }
    
    #Usage
    Get-SPSiteLastAccessInfo -IncludePersonalSites $true -OutputPath "C:\LastAccess1.txt"
    #Or
    Get-SPSiteLastAccessInfo -IncludePersonalSites $false -OutputPath "C:\LastAccess1.txt"


    Jerry Yasir - Office Server & Services MVP/MCT Hewlett Packard Enterprise - If this reply helped you resolve your issue, please propose as answer. It may help other community members. Thanks!

    • Proposed as answer by Victoria Xia Friday, March 4, 2016 1:56 PM
    • Marked as answer by Sara Fan Tuesday, March 8, 2016 1:21 AM
    Monday, February 29, 2016 7:11 PM
  • I agreed with above given suggestions.

    As an alternative and if you wish to get more detailed reports of such changes/access on SharePoint server, this SharePoint auditing application should be an appropriate solution to your concern.

    Tuesday, March 1, 2016 9:57 AM