Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Powershell to Set SetCutoffMaxBuckets value
function LoadSharePointPowerShellEnvironment
{
write-host "Setting up PowerShell environment for SharePoint..." -foregroundcolor Green
Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue
write-host "SharePoint PowerShell Snapin loaded." -foregroundcolor Green
}
function SetCutoffMaxBuckets($ManagedProperty,$CutoffMaxBuckets)
{
try
{
Write-Host "********Input Values ***************" -Fore green
Write-Output ("Managed Property Name: '$ManagedProperty'.")
Write-Output ("CutoffMaxBuckets Size: '$CutoffMaxBuckets'.")
Write-Host "*************************************" -Fore green
$mp = Get-SPEnterpriseSearchMetadataManagedProperty -SearchApplication $searchapp -Identity $ManagedProperty
if(-not $mp)
{
Write-Host "Could not get Managed Property Name '$ManagedProperty'. Managed properties will not be configured." -Fore Red
return
}
if ($CutoffMaxBuckets -ne $null)
{
#$mp.RefinerConfiguration.CutoffMaxBuckets
$mp.RefinerConfiguration.CutoffMaxBuckets = [int]$CutoffMaxBuckets
$mp.Update()
Write-Output ("Updated CutoffMaxBuckets size to: '$CutoffMaxBuckets'")
}
}
catch
{
write-host $_.exception
}
}
LoadSharePointPowerShellEnvironment
$searchServiceName= "Search Service Application"
$searchapp = Get-SPEnterpriseSearchServiceApplication $searchServiceName
if (-not $searchapp)
{
Write-Host "Could not get search application ($searchServiceName). Managed properties will not be configured." -Fore Red
return
}
Write-Host -ForegroundColor yellow "Process Start"
Write-Host -ForegroundColor yellow "**********************************************************************"
#SetCutoffMaxBuckets "ManagedPropertyName" #Value as integer 10000
SetCutoffMaxBuckets "RefinerName" 10000
$searchapp.Update()
Write-Host -ForegroundColor yellow "Process Complete"
Write-Host -ForegroundColor yellow "**********************************************************************"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment