### Crawl Status script - outputs crawl status, schedule details, start address, last start and completed times
###################################################################
Param ([string]$sspURL)
$description =@'
describes crawl status
'@
### error handling ###
$scriptname = $MyInvocation.MyCommand.Name
$scriptpath = $MyInvocation.MyCommand.Path
$transcriptFile = "C:\Install\Logs\Powershell_$scriptname.log"
Start-Transcript $transcriptFile -append -force
Write-Output "Starting Script: $scriptpath"
Write-Output $description
$error.Clear()
$erroractionpreference="Stop"
$ReportErrorShowExceptionclass=$true
$ReportErrorShowInnerexception=$true
$ReportErrorShowSource=$true
$ReportErrorShowStackTrace=$true
trap {
$errorRecord = $error[0]
Write-Output "ErrorRecord:"
$errorRecord | Format-List * -Force | Out-Default
Write-Output "CategoryInfo:"
$errorRecord.CategoryInfo | Format-List * -Force | Out-Default
Write-Output "ErrorDetails:"
$errorDetails = $errorRecord.ErrorDetails
Write-Output "Message:"
$errorDetails.Message | Out-Default
Write-Output "RecommendedAction:"
$errorDetails.RecommendedAction | Out-Default
Write-Output "FullyQualifiedErrorId:"
$errorRecord.FullyQualifiedErrorId | Out-Default
Write-Output "InvocationInfo:"
$errorRecord.InvocationInfo | Format-List * -Force | Out-Default
Write-Output "TargetObject:"
$errorRecord.TargetObject | Format-List * -Force | Out-Default
Write-Output "Exception:"
$Exception = $errorRecord.Exception
for ($i = 0; $Exception; $i++, ($Exception = $Exception.InnerException))
{$Exception | Format-List * -Force | Out-Default}
;break
}
#####################################################################
### loading assemblies ###
[void][System.Reflection.Assembly]::Load("Microsoft.Office.Server.Search, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")
[void][System.Reflection.Assembly]::Load("Microsoft.Sharepoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")
[void][System.Reflection.Assembly]::Load("Microsoft.Office.Server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")
#####################################################################
### $sspURL: e.g. "http://ssp.mydomain/ssp/admin"
$site = new-object Microsoft.SharePoint.SPSite($sspURL)
### getting spsite from $Url
$searchContext = [Microsoft.Office.Server.Search.Administration.SearchContext]::GetContext($site)
### getting searchContext from spsite
$content = new-object Microsoft.Office.Server.Search.Administration.Content($searchContext)
### getting admin content from searchContext
### Initializes a new instance of the Content class.
#####################################################################
$df = "local office SharePoint server sites"
$ContentSourceCollection = $content.ContentSources
$local = $ContentSourceCollection[$df]
Write-output "The crawl status is: " $local.crawlstatus
Write-output "The start time of the last crawl: " $local.CrawlStarted
Write-output "The time of the last completed crawl of a content source is: " $local.CrawlCompleted
Write-output "The content source's schedule of full crawls is: " $local.FullCrawlSchedule
Write-output "The content source's schedule of incremental crawls is: " $local.IncrementalCrawlSchedule
Write-output "The StartAddresses: " $local.StartAddresses
stop-transcript
#####################################################################
Param ([string]$sspURL)
$description =@'
describes crawl status
'@
### error handling ###
$scriptname = $MyInvocation.MyCommand.Name
$scriptpath = $MyInvocation.MyCommand.Path
$transcriptFile = "C:\Install\Logs\Powershell_$scriptname.log"
Start-Transcript $transcriptFile -append -force
Write-Output "Starting Script: $scriptpath"
Write-Output $description
$error.Clear()
$erroractionpreference="Stop"
$ReportErrorShowExceptionclass=$true
$ReportErrorShowInnerexception=$true
$ReportErrorShowSource=$true
$ReportErrorShowStackTrace=$true
trap {
$errorRecord = $error[0]
Write-Output "ErrorRecord:"
$errorRecord | Format-List * -Force | Out-Default
Write-Output "CategoryInfo:"
$errorRecord.CategoryInfo | Format-List * -Force | Out-Default
Write-Output "ErrorDetails:"
$errorDetails = $errorRecord.ErrorDetails
Write-Output "Message:"
$errorDetails.Message | Out-Default
Write-Output "RecommendedAction:"
$errorDetails.RecommendedAction | Out-Default
Write-Output "FullyQualifiedErrorId:"
$errorRecord.FullyQualifiedErrorId | Out-Default
Write-Output "InvocationInfo:"
$errorRecord.InvocationInfo | Format-List * -Force | Out-Default
Write-Output "TargetObject:"
$errorRecord.TargetObject | Format-List * -Force | Out-Default
Write-Output "Exception:"
$Exception = $errorRecord.Exception
for ($i = 0; $Exception; $i++, ($Exception = $Exception.InnerException))
{$Exception | Format-List * -Force | Out-Default}
;break
}
#####################################################################
### loading assemblies ###
[void][System.Reflection.Assembly]::Load("Microsoft.Office.Server.Search, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")
[void][System.Reflection.Assembly]::Load("Microsoft.Sharepoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")
[void][System.Reflection.Assembly]::Load("Microsoft.Office.Server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")
#####################################################################
### $sspURL: e.g. "http://ssp.mydomain/ssp/admin"
$site = new-object Microsoft.SharePoint.SPSite($sspURL)
### getting spsite from $Url
$searchContext = [Microsoft.Office.Server.Search.Administration.SearchContext]::GetContext($site)
### getting searchContext from spsite
$content = new-object Microsoft.Office.Server.Search.Administration.Content($searchContext)
### getting admin content from searchContext
### Initializes a new instance of the Content class.
#####################################################################
$df = "local office SharePoint server sites"
$ContentSourceCollection = $content.ContentSources
$local = $ContentSourceCollection[$df]
Write-output "The crawl status is: " $local.crawlstatus
Write-output "The start time of the last crawl: " $local.CrawlStarted
Write-output "The time of the last completed crawl of a content source is: " $local.CrawlCompleted
Write-output "The content source's schedule of full crawls is: " $local.FullCrawlSchedule
Write-output "The content source's schedule of incremental crawls is: " $local.IncrementalCrawlSchedule
Write-output "The StartAddresses: " $local.StartAddresses
stop-transcript
#####################################################################
No comments:
Post a Comment