Encuentre las 10 colecciones de sitios principales según su uso durante el último mes
PowerShell Script para encontrar las 10 principales colecciones de sitios de SharePoint 2007 según sus visitas de uso:
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
#Functions to Imitate SharePoint 2010 Cmdlets in MOSS 2007
function global:Get-SPWebApplication($WebAppURL)
{
return [Microsoft.SharePoint.Administration.SPWebApplication]::Lookup($WebAppURL)
}
function global:Get-SPSite($url) {
return new-Object Microsoft.SharePoint.SPSite($url)
}
function global:Get-SPWeb($url) {
$site= New-Object Microsoft.SharePoint.SPSite($url)
if($site -ne $null) {
$web=$site.OpenWeb();
}
return $web
}
#Get all site collections of the provided web application
$WebApp = Get-SPWebApplication "https://intranet.crescent.com"
$SitesCollection = $WebApp.Sites
$UsageDataCollection = @()
#Iterate through each site collection
ForEach($site in $SitesCollection)
{
$web = Get-SPWeb $site.URL
$LastMonthUsage = ($web.GetUsageData("url", "lastMonth") | sort 'Total Hits')
If($LastMonthUsage -ne $null)
{
$totalHits = ($LastMonthUsage | Measure-Object 'Total Hits' -Sum | Select -expand Sum)
$UsageDataResult = New-Object PSObject
$UsageDataResult | Add-Member -type NoteProperty -name "Site Collection URL" -value $site.URL
$UsageDataResult | Add-Member -type NoteProperty -name "Site Title" -value $web.title
$UsageDataResult | Add-Member -type NoteProperty -name "Total Hits" -value $totalHits
$UsageDataCollection += $UsageDataResult
#Clear variables
$LastMonthUsage = $null
$tHits = $null
}
}
$UsageDataCollection | sort-object "Total Hits" -descending | select-object -first 10 | Export-csv "Top10Sites.csv" -notypeinformation
Para SharePoint 2010 y versiones posteriores, utilice el elemento web Web Analytics.