SharePoint 2010 & SharePoint 2007 – Powershell script for finding site Url, Title,user Count, Primary & Secondary Site collection admins, Usage, Hits, views, Created Date, last modifed date
[System.Reflection.Assembly]::Load(“Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”) # get local farm $farm = [Microsoft.SharePoint.Administration.SPFarm]::Local # get web services from local farm $websrvcs = $farm.Services | where -FilterScript {$_.GetType() -eq [Microsoft.SharePoint.Administration.SPWebService]} # format for .csv file output $outputToCSV = @() function CheckedOutItems() { # get all web services available in the farm foreach ($websrvc in $websrvcs) { # retrieve web applications foreach ($webApp in $websrvc.WebApplications) { # now get site collections from the web application foreach ($site in $webApp.Sites) { # process each web site Try { foreach ($web in $site.AllWebs) { $siteUrl = $web.Url $siteName = $web.Title $siteUserCnt = $web.AllUsers.Count $PimarySiteAdmin = $site.Owner.Name $SecondarySiteAdmin = $site.SecondaryContact.Name $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; "Primary site collection admin"= $PimarySiteAdmin; "Secondary site collection admin"=$SecondarySiteAdmin; "Total Users" =$siteUserCnt;"Size" = $siteusage; "Date Last Modified" = $LastModified; "Days Last Update" = $LastUpdate; "Hits" =$Hits; "Date Created" =$Created } $file_date = get-date -format M-d-yyyy $file_name = "$env:USERPROFILE\Desktop\NoCheckedInVersion"+ $file_date + ".csv" $outputToCSV | ConvertTo-Csv -notype > $file_name } # end $site.AllWebs loop } # end Try statement # General catch exceptions Catch { "General Exceptions caught: " >> "$env:USERPROFILE\Desktop\errorlog.txt" $_.Exception.Message >> "$env:USERPROFILE\Desktop\errorlog.txt" }# end general catch statement } } } } # Make a call to the function CheckedOutItems
fuente: https://santoshksp.wordpress.com/2012/10/30/powershell-script-for-sharepoint-2010-sharepoint-2007-site-usage-report/
Comentarios