9/5/2010
LifeCycle Solutions - Home ( the software development blog )
 

<September 2010>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789

Subscribe to this feed:

RSS 2.0 | Atom 1.0 |CDF






Thursday, May 06, 2010

SharePoint 2010 has fairly rich Web Analytics and usage reporting functionality.  You can see plenty of useful stats and charts across your farm.  However, at farm level, it’s missing an important feature – email subscriptions.  In site collection admin, you can subscribe to stats for a given site collection, but in Central Admin (AFAIK), you can’t set up email subscriptions on the overall farm stats, or stats for an entire web app.

Hopefully, this feature will be added in the future, but as a quick fix, I whipped together a wonderful hack that can be used to scrape-and-send just about any of the reports- or other content as well.

$wc = new-object net.webclient
$cred = [System.Net.CredentialCache]::DefaultCredentials;
$wc.Credentials = $cred
 
$reportMarkup = $wc.DownloadString("http://yourcentraladmin/_layouts/WebAnalytics/Report.aspx?t=SummaryReport&l=wa&Id=http%3a%2f%2fyourserver%2f&WebAppName=YourWebApp&DURATION=7&CD=false&SHOWANALYZETAB=1")
$reportStart = $reportMarkup.IndexOf('<table class="ms-listviewtable"')
$reportEnd = $reportMarkup.IndexOf('</table>', $reportStart) + 8
$reportMarkup = $reportMarkup.Substring($reportStart, $reportEnd - $reportStart)
 
Send-MailMessage -To you@yourcompany.com -From sharepoint@yourcompany.com -Subject "Web Analytics" -Body $reportMarkup -BodyAsHtml -SmtpServer smtpiron

This script just downloads the page, scrapes the relevant area, and sends it off as email.  To use, you’ll need to fix up the url, scraping code, and mail addresses as needed, then schedule in scheduled tasks.

With a little more effort, you could even scrape together an ‘admin’ report to give you a quick glance at the most relevant Central Admin content such as health, analytics, and search crawl info.

Posted by Daniel Root

© 2006 LifeCycle Solutions, LLC | All Rights Reserved