All, I'm in need to trying to get stats from a legacy SharePoint 2010 environment and was wondering what others have done for this as it appears in my case logging and auditing logs were never turned on so the OOTB user reports show empty.
The following Powershell - does return correct results - but the hit column for all the sites shows the same number. If I run this same script in a SharePoint 2013 environment, it works fine in regard to the hit count. Therefore, any guidance or possibly tweak to this Powershell would be appreciated:
#######################################
#Script is to be utilized to output stats from a SharePoint 2010 environment
#Note can also be utilized with a SharePoint 2013 environment.
#
#######################################
$Site=Get-SPSite https://mysite.testsite.com
foreach ($web in $site.AllWebs) {
$siteUrl = $web.Url
$siteName = $web.Title
$siteUserCnt = $web.AllUsers.Count
$siteusage = $site.Usage.Storage/1MB
$Hits = $site.Usage.Hits
$Created = [datetime]$web.Created
$LastModified = $Web.LastItemModifiedDate
$SnapShot = (get-date)
$LastUpdate = ($SnapShot – [datetime]$LastModified)
$outputToCSV = New-Object PSObject -Property @{"Site Title" = $siteName
"Url" = $siteUrl
"Total Users" =$siteUserCnt
"Size" = $siteusage
"Date Last Modified" = $LastModified
"Days Last Update" = $LastUpdate
"Hits" =$Hits
"Date Created" =$Created
}
$outputToCSV | out-file -FilePath "C:\PowershellOutput\site_stats.csv" -Append
}












