Powershell script for SharePoint 2010 Site collection Top Visitor report
-
08-02-2021 - |
Question
Right now from Site Collection Analytics - Top Visitor report we are getting only 2000 users, there should be more than 2000 user. how we can get all the users who have accessed for last one year.
Can we do it by using sharepoint power shell command or script to get Top Visitor Report/ excel file for SharePoint 2010 site Usage Web Analytics Service.
Solution
try the below code,
$server = "CentralAdminUrl"
$webAppName = "MyWebApp"
$sd = 01/01/2015
$ed = 01/31/2015
$wc = New-Object System.Net.WebClient
$wc.Credentials = [System.Net.CredentialCache]::DefaultCredentials
$url = $server+ "/_layouts/WebAnalytics/Report.aspx?t=TopVisitorsReport&l=wa&id=https%3a%2f%2f"+$id+"%2f&WebAppName="+$webAppName+"&CD=true&SD="+$sd+"&ED="+$ed+"&SHOWANALYZETAB=1&Export=1"
$file = "d:\Logs\$(get-date -f yyyy-MM)-WebApp-TopVisitors.csv"
$wc.DownloadFile($url, $file)
Go in Central Admin on your SharePoint server and look at the URL for the web analytics reports. You can just create a web client object in your code and use that url to get the report.
OTHER TIPS
For Site collection Top Visitor report I used work arround mentioned in below link
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange