当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] 根据上个月的使用情况查找排名前 10 的网站集

作者:精品下载站 日期:2024-12-14 13:42:34 浏览:13 分类:玩电脑

根据上个月的使用情况查找排名前 10 的网站集


PowerShell 脚本根据其使用点击率查找排名前 10 的 SharePoint 2007 网站集:


[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 

对于 SharePoint 2010 及更高版本,请使用 Web Analytics Web 部件!

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯