Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Add-PSSnapin Microsoft.SharePoint.PowerShell
- function Get-CrawlStatisticsForUrl
- {
- [cmdletbinding()]
- param
- (
- [Parameter(Mandatory=$true)][string]$Url,
- [Parameter(Mandatory=$false)][DateTime]$StartDate = [DateTime]::MinValue,
- [Parameter(Mandatory=$false)][DateTime]$EndDate = [DateTime]::MaxValue,
- [Parameter(Mandatory=$false)][switch]$ExactMatch
- )
- begin
- {
- $ssa = Get-SPEnterpriseSearchServiceApplication
- $crawLog = New-Object Microsoft.Office.Server.Search.Administration.CrawlLog($ssa)
- $statusMessageCounts = [PSCustomObject] @{
- Url = $Url
- Successes = 0
- Warnings = 0
- Errors = 0
- }
- }
- process
- {
- if ($crawLog )
- {
- $dt = $crawLog.GetCrawledUrls(
- $false, # GetCountOnly
- [int]::MaxValue, # maxRows
- $Url, # urlQueryString
- (-not $ExactMatch.IsPresent), # isLike
- -1, # contentSourceID -1 == 'All'
- -1, # errorLevel -1 == 'All'
- -1, # errorID -1 == 'All"
- $StartDate, # startDateTime
- $EndDate # endDateTime
- )
- foreach( $row in $dt.Rows )
- {
- switch( $row.ErrorLevel )
- {
- 0 { $statusMessageCounts.Successes++ }
- 1 { $statusMessageCounts.Warnings++ }
- 2 { $statusMessageCounts.Errors++ }
- }
- }
- }
- }
- end
- {
- $statusMessageCounts
- }
- }
- $results = @()
- # get the stats for all the sites in a specific database
- Get-SPSite -Limit All -ContentDatabase "SP2013_CONTENT_001" | % { $results += Get-CrawlStatisticsForUrl -Url $_.Url }
- # dump stats to screen
- $results | SORT Url | FT Url, Successes, Warnings, Errors -AutoSize
Add Comment
Please, Sign In to add comment