-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
178 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
############################################################################################################################################ | ||
# Script that allows to get all the query suggestions already defined in a SharePoint farm. | ||
# Required Parameters: | ||
# ->$sTheasurusFilePath: Theasurus File Path | ||
############################################################################################################################################ | ||
|
||
If ((Get-PSSnapIn -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null ) | ||
{ Add-PSSnapIn -Name Microsoft.SharePoint.PowerShell } | ||
|
||
$host.Runspace.ThreadOptions = "ReuseThread" | ||
|
||
#Definition of the function that gets current query suggestions in the SharePoint farm | ||
function Get-QuerySuggestions | ||
{ | ||
try | ||
{ | ||
Write-Host "Getting all the query suggestions..." -ForegroundColor Green | ||
$ssaSearchApp = Get-SPEnterpriseSearchServiceApplication -Identity “Search Service App" | ||
$spSearchOwner = Get-SPEnterpriseSearchOwner -Level SSA | ||
Get-SPEnterpriseSearchQuerySuggestionCandidates -SearchApplication $ssaSearchApp -Owner $spSearchOwner | ||
} | ||
catch [System.Exception] | ||
{ | ||
write-host -f red $_.Exception.ToString() | ||
} | ||
} | ||
|
||
Start-SPAssignment –Global | ||
Get-QuerySuggestions | ||
Stop-SPAssignment –Global | ||
|
||
Remove-PSSnapin Microsoft.SharePoint.PowerShell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
############################################################################################################################################ | ||
# Script that allows to import query suggestions to the SharePoint Search. | ||
# Required Parameters: | ||
# ->$sInputfile: Query suggestions file. | ||
# ->$sLanguage: Language for the Query Suggestions. | ||
############################################################################################################################################ | ||
|
||
If ((Get-PSSnapIn -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null ) | ||
{ Add-PSSnapIn -Name Microsoft.SharePoint.PowerShell } | ||
|
||
$host.Runspace.ThreadOptions = "ReuseThread" | ||
|
||
#Definition of the function that imports new query suggestions to SharePoint | ||
function Import-QuerySuggestions | ||
{ | ||
param ($sInpuntFile,$sLanguage) | ||
try | ||
{ | ||
Write-Host "Importing Query Suggestions.." -ForegroundColor Green | ||
#Checking if the query suggestions file exists | ||
$bFileExists = (Test-Path $sInputFile -PathType Leaf) | ||
if ($bFileExists) { | ||
"Loading $sInputFile for processing..." | ||
$tblData = Import-CSV $sInputFile | ||
} else { | ||
Write-Host "File $sInputFile not found. Stopping the Import Process!" -foregroundcolor Red | ||
exit | ||
} | ||
|
||
$ssaSearchApp = Get-SPEnterpriseSearchServiceApplication -Identity “Search Service App" | ||
$spSearchOwner = Get-SPEnterpriseSearchOwner -Level SSA | ||
|
||
#Processing the file data | ||
foreach ($row in $tblData){ | ||
$sQuerySuggestion=$row.QuerySuggestion.ToString() | ||
Write-Host "Adding $sQuerySuggestion as a Query Suggestion" | ||
New-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $ssaSearchApp -Language $sLanguage -Type QuerySuggestionAlwaysSuggest -Name $sQuerySuggestion -Owner $spSearchOwner | ||
} | ||
|
||
#Starting the Timer Job that makes available new query suggestions | ||
$qsTimerJob = Get-SPTimerJob -type "Microsoft.Office.Server.Search.Administration.PrepareQuerySuggestionsJobDefinition" | ||
Write-Host "Starting " $qsTimerJob.Name " Timber Job" -ForegroundColor Green | ||
$qsTimerJob.RunNow() | ||
Write-Host "Query Suggestions successfully imported!!" -ForegroundColor Green | ||
|
||
} | ||
catch [System.Exception] | ||
{ | ||
write-host -f red $_.Exception.ToString() | ||
} | ||
} | ||
|
||
Start-SPAssignment –Global | ||
#Archivo con los Usuarios | ||
$ScriptDir = Split-Path -parent $MyInvocation.MyCommand.Path | ||
$sInputFile=$ScriptDir+ "\QuerySuggestions_Madrid.txt" | ||
$sLanguage="ES-es" | ||
Import-QuerySuggestions -sInpuntFile $sInputFile -sLanguage $sLanguage | ||
Stop-SPAssignment –Global | ||
|
||
Remove-PSSnapin Microsoft.SharePoint.PowerShell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
############################################################################################################################################ | ||
# Script that allows to remove query suggestions from the SharePoint Search. | ||
# Required Parameters: | ||
# ->$sQuerySuggestion: Query suggestion to rmeove | ||
# ->$sLanguage: Language for the Query Suggestions. | ||
############################################################################################################################################ | ||
|
||
If ((Get-PSSnapIn -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null ) | ||
{ Add-PSSnapIn -Name Microsoft.SharePoint.PowerShell } | ||
|
||
$host.Runspace.ThreadOptions = "ReuseThread" | ||
|
||
#Definition of the function that removes a query suggestion from the SharePoint Search | ||
function Remove-QuerySuggestions | ||
{ | ||
param ($sQuerySuggestion,$sLanguage) | ||
try | ||
{ | ||
Write-Host "Removing Query Suggestion $sQuerySuggestion" -ForegroundColor Green | ||
$ssaSearchApp = Get-SPEnterpriseSearchServiceApplication -Identity “Search Service App" | ||
$spSearchOwner = Get-SPEnterpriseSearchOwner -Level SSA | ||
Remove-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $ssaSearchApp -Language $sLanguage -Type QuerySuggestionAlwaysSuggest -Identity $sQuerySuggestion -Owner $spSearchOwner -Confirm:$false | ||
|
||
#Starting the Timer Job that makes available new query suggestions | ||
$qsTimerJob = Get-SPTimerJob -type "Microsoft.Office.Server.Search.Administration.PrepareQuerySuggestionsJobDefinition" | ||
Write-Host "Starting " $qsTimerJob.Name " Timber Job" -ForegroundColor Green | ||
$qsTimerJob.RunNow() | ||
Write-Host "Query Suggestion $sQuerySuggestion successfully removed!!" -ForegroundColor Green | ||
|
||
} | ||
catch [System.Exception] | ||
{ | ||
write-host -f red $_.Exception.ToString() | ||
} | ||
} | ||
|
||
Start-SPAssignment –Global | ||
$sLanguage="ES-es" | ||
$sQuerySuggestion="Atlético de Madrid" | ||
Remove-QuerySuggestions -sQuerySuggestion $sQuerySuggestion -sLanguage $sLanguage | ||
Stop-SPAssignment –Global | ||
|
||
Remove-PSSnapin Microsoft.SharePoint.PowerShell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
QuerySuggestion | ||
Madrid | ||
Real Madrid | ||
Atlético de Madrid | ||
Comunidad de Mardid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
############################################################################################################################################ | ||
# Script that allows to find all the ocurrences for a Correlation ID in the SharePoint Loigs | ||
# Required Parameters: | ||
# -> $sCorrelationID: Correlation ID to look for | ||
# -> $sLogFile: Name of the log file where the information obtained is stored | ||
############################################################################################################################################ | ||
|
||
If ((Get-PSSnapIn -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null ) | ||
{ Add-PSSnapIn -Name Microsoft.SharePoint.PowerShell } | ||
|
||
$host.Runspace.ThreadOptions = "ReuseThread" | ||
|
||
#Definition of the function that finds a specific correlation ID in SharePoint Log Files | ||
function Find-CorrelationID | ||
{ | ||
param ($sCorrelationID,$sLogFile) | ||
try | ||
{ | ||
Write-Host "Finding the correlation ID $sCorrelationID in SharePoint Logs" -foregroundcolor Green | ||
Get-SPLogEvent | ?{$_.Correlation -eq $sCorrelationID} | select Area, Category, Level, EventID, Message | Format-List > $sLogFile | ||
} | ||
catch [System.Exception] | ||
{ | ||
write-host -f red $_.Exception.ToString() | ||
} | ||
} | ||
|
||
Start-SPAssignment –Global | ||
#Calling the function | ||
$sCorrelationID="9fd3251e-b81f-45f8-b2b7-044b64418f55" | ||
$sScriptDir = Split-Path -parent $MyInvocation.MyCommand.Path | ||
$sLogFile=$sScriptDir + "\CorrelationIDLog.log" | ||
Find-CorrelationID -sCorrelationID $sCorrelationID -sLogFile $sLogFile | ||
Stop-SPAssignment –Global | ||
|
||
Remove-PSSnapin Microsoft.SharePoint.PowerShell | ||
|