We are working on SP 2013 On Premise Environment. For archival process of old site collections, we are trying to find out site collections which have not been accessed since 1st Jan 2018 in a web application.
Using PowerShell for this, once we loop through all the site collections we are currently performing a check in the following manner :
foreach($sc in $webapplication | Get-SPSite -Limit All)
{
if ($sc.RootWeb.LastItemModifiedDate -lt $lastDate)
{
Write-Host "Site is old…" + $sc.Title
Add-Content -Path $outputPath -Value "$($sc.URL)"
}
}
However, the list of site collections which we get in this manner is not accurate since we have manually checked some site collections and found that they have not been updated in over a year and still they are showing up in the output. One possible explanation for this is due to the timer jobs which run on a farm level and so if for instance a user is removed or added the last item modified date for site collections change in this process.
Note: We need this only for site collections and not for Sub sites. For Sub sites we can do :
$su = Get-SPWeb -identity “Site collection url”
$u. LastItemModifiedDate
And for Site Collection we can also use LastContentModifiedDate. However, that again does not give us accurate results.
Could anyone suggest if there is a workaround for the above problem, Any Thoughts/suggestions are welcome