0

我想检索在一个环境中创建的快速搜索范围并在新环境中恢复它们。有人试过吗?

4

1 回答 1

0

我有这个让你开始......

首先你必须导出范围,然后是范围规则:

# 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

现在导入范围:

# 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))
}

对于搜索范围,我不确定这是否可行,您可能必须一次导入一个范围,并指定规则适用的范围。

# 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 

然后就可以开始范围更新编译了

# Start Scope Update Compilation to add the new rules
Write-Host Start Scope Update Compilation...
$searchApp.StartScopesCompilation()
于 2014-05-16T17:45:48.030 回答