Execution Flow
This is a read-only diagnostic — it never changes the setting. To apply the recommendation, use
Set-sqmServerSetting or dbatools' Set-DbaSpConfigure -Name 'cost threshold for parallelism' -Value 50. Pairs naturally with Test-sqmMaxDop as the two classic "first things to check" on a new SQL Server instance.Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| -SqlInstance | String | Optional | SQL Server instance. Default: local computer name. |
| -SqlCredential | PSCredential | Optional | SQL authentication credential for the connection. |
| -MinRecommendedValue | Int (1–32767) | Optional | Minimum acceptable value. Default: 50, or the module config key CheckCostThresholdMin if set and this parameter wasn't given explicitly. |
| -EnableException | Switch | Optional | Throw a terminating exception instead of Write-Error. |
Return Value
Returns a single PSCustomObject with: SqlInstance, CurrentValue, RecommendedMinValue, Status (OK, Warning, or Error), Message.
Examples
Example 1 — Check against the default minimum (50)
Test-sqmCostThreshold -SqlInstance "SQL01"Example 2 — Use a custom minimum
Test-sqmCostThreshold -SqlInstance "SQL01" -MinRecommendedValue 25Example 3 — Sweep a server list, show only warnings
"SQL01","SQL02" | ForEach-Object { Test-sqmCostThreshold -SqlInstance $_ } |
Where-Object Status -eq 'Warning'