$domain = (Get-ChildItem env:userdomain).value $tempsqlserver = (Get-ChildItem env:computername).value $tempsearchserver = (Get-ChildItem env:computername).value $tempcrawluser = $domain.ToString() + '\sp_content' $databaseName = "Search_Service_DB" $searchSAName = "SharePoint Server Search" $saAppPoolName = "Default SharePoint Service App Pool" # Make sure this matches an existing service app pool $crawlPwd = "pass@word1" # Make sure you escape any $ characters in the password $sqlserver = Read-Host -Prompt "Enter SQL Instance name. Press Enter for $tempsqlserver" If ($sqlserver -eq "") {$sqlserver = $tempsqlserver} $searchServerName = Read-Host -Prompt "Enter Search Server name. Press Enter for $tempsearchserver" If ($searchServerName -eq "") {$searchServerName = $tempsearchserver} $crawlUser = Read-Host -Prompt "Enter Content Crawl Username. Press Enter for $tempcrawluser" If ($crawlUser -eq "") {$crawlUser = $tempcrawluser} ##START SEARCH Write-Host "Creating Search Service and Proxy..." Write-Host " Starting Services..." Start-SPEnterpriseSearchServiceInstance $searchServerName Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $searchServerName Write-Host " Creating Search Application..." $searchApp = New-SPEnterpriseSearchServiceApplication -Name $searchSAName -ApplicationPool $saAppPoolName -DatabaseServer $sqlserver -DatabaseName $databaseName $searchInstance = Get-SPEnterpriseSearchServiceInstance $searchServerName Write-Host " Creating Administration Component..." $searchApp | Get-SPEnterpriseSearchAdministrationComponent | Set-SPEnterpriseSearchAdministrationComponent -SearchServiceInstance $searchInstance ##Crawl Write-Host " Creating Crawl Component..." $InitialCrawlTopology = $searchApp | Get-SPEnterpriseSearchCrawlTopology -Active $CrawlTopology = $searchApp | New-SPEnterpriseSearchCrawlTopology $CrawlDatabase = ([array]($searchApp | Get-SPEnterpriseSearchCrawlDatabase))[0] $CrawlComponent = New-SPEnterpriseSearchCrawlComponent -CrawlTopology $CrawlTopology -CrawlDatabase $CrawlDatabase -SearchServiceInstance $searchInstance $CrawlTopology | Set-SPEnterpriseSearchCrawlTopology -Active ## Got Error here Write-Host -ForegroundColor white " Waiting for the old crawl topology to become inactive" -NoNewline do {write-host -NoNewline .;Start-Sleep 6;} while ($InitialCrawlTopology.State -ne "Inactive") $InitialCrawlTopology | Remove-SPEnterpriseSearchCrawlTopology -Confirm:$false Write-Host ##Query Write-Host " Creating Query Component..." $InitialQueryTopology = $searchApp | Get-SPEnterpriseSearchQueryTopology -Active $QueryTopology = $searchApp | New-SPEnterpriseSearchQueryTopology -Partitions 1 $IndexPartition= (Get-SPEnterpriseSearchIndexPartition -QueryTopology $QueryTopology) $QueryComponent = New-SPEnterpriseSearchQuerycomponent -QueryTopology $QueryTopology -IndexPartition $IndexPartition -SearchServiceInstance $searchInstance $PropertyDatabase = ([array]($searchApp | Get-SPEnterpriseSearchPropertyDatabase))[0] $IndexPartition | Set-SPEnterpriseSearchIndexPartition -PropertyDatabase $PropertyDatabase $QueryTopology | Set-SPEnterpriseSearchQueryTopology -Active Write-Host " Creating Proxy..." $searchAppProxy = New-SPEnterpriseSearchServiceApplicationProxy -Name "$searchSAName Proxy" -SearchApplication $searchSAName > $null # Set Default Content Crawl Account $c = New-Object Microsoft.Office.Server.Search.Administration.Content($searchapp) $c.SetDefaultGatheringAccount($crawlUser, (ConvertTo-SecureString $crawlPwd -AsPlainText -force)) #####END SEARCH