Monday, 6 June 2011

edit content source powershell script for MOSS 2007

Param ([string]$sspURL, [string]$sal1)
$description =@'

configures the default content source - deletes all start addresses and then adds portal start address and sets incremental crawl schedule
'@


#Edit default content source to replace it with $Sal1 then and set incremental crawl schedule to 5PM every weekday

#####################################################################
[System.Reflection.Assembly]::Load("Microsoft.Office.Server.Search, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")
[System.Reflection.Assembly]::Load("Microsoft.Sharepoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")
[System.Reflection.Assembly]::Load("Microsoft.Office.Server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")

#####################################################################

### e.g. $sspURL = http://breakfast/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
###Initialize a new instance of the Content class.

$df = "local office SharePoint server sites"

$ContentSourceCollection = $content.ContentSources

$local = $ContentSourceCollection[$df]

$sac = $local.startaddresses

$sac.clear();

### e.g. $sal1 = http://test2.com/

$sac.add($sal1)

#####################################################################

$ContentSourceCollection = $content.ContentSources

$local = $ContentSourceCollection[$df]

#set context

$dailyIncrementalSchedule = new-object Microsoft.Office.Server.Search.Administration.WeeklySchedule($searchContext)

#set start hour

$hour = 17

$dailyIncrementalSchedule.starthour = $hour

$local.incrementalcrawlschedule = $dailyincrementalschedule

$local.Update();

#set weekly schedule

$dailyIncrementalSchedule.DaysOfWeek = [Microsoft.Office.Server.Search.Administration.DaysOfWeek]::Weekdays

$local.incrementalcrawlschedule = $dailyincrementalschedule

$local.update()



#####################################################################

No comments:

Post a Comment

SharePoint Information Architecture Diagram

Here is the template I use for Information Architecture designs. It's built using Mindjet and I flesh the nodes out with the low level d...