I want retrieve the fast search scopes created in one environment and restore them in a new environment.Has anybody tried this?
Asked
Active
Viewed 970 times
1 Answers
0
I have this to get you started...
First you have to export the scopes, and then the scope rules:
# Search Service Application Name
$searchAppName = 'Search Service Application'
# Get Search Service Application
$searchApp = Get-SPEnterpriseSearchServiceApplication $searchAppName
# Get the Scopes
$scopes = Get-SPEnterpriseSearchQueryScope -SearchApplication $searchApp
# Export scopes to CSV
$scopes | Export-Csv -Path Scopes.csv
# Get the Scope Rules
$scopeRules = $scopes | Get-SPEnterpriseSearchQueryScopeRule
# Export scope rules to XML
$scopeRules | Export-Clixml -Path ScopeRules.xml
Now to import the scopes:
# Search Service Application Name
$searchAppName = 'Search Service Application'
# Get Search Service Application
$searchApp = Get-SPEnterpriseSearchServiceApplication $searchAppName
# Get .CSV file with Search Scope information
$File = 'Scopes.csv'
# Loop through the CSV file entries
$csvData = Import-Csv $File | ForEach-Object {
Write-Host Creating Search Scope... $_.Name
# Create New Search Scope
$new = New-SPEnterpriseSearchQueryScope -SearchApplication $searchApp -Name $_.Name -Description $_.Description -DisplayInAdminUI ([System.Convert]::ToBoolean($_.DisplayInAdminUI))
}
For the search scopes, I am not sure if this will work, you may have to import them one scope at a time, and specify the scope that the rules apply to.
# Get .XML file with Search Scope Rule information
$File = 'ScopeRules.xml'
#Import XML
$scopeRules = Import-Clixml $File
# Create New Search Scope Rule??
$scopeRules | New-SPEnterpriseSearchQueryScopeRule
Then you can start scope update compilation
# Start Scope Update Compilation to add the new rules
Write-Host Start Scope Update Compilation...
$searchApp.StartScopesCompilation()

HAL9256
- 12,384
- 1
- 34
- 46