Commands / Test-sqmMaxMemory
SQL Configuration

Test-sqmMaxMemory

Reads the current "max server memory (MB)" setting and checks it against a tolerance band around a target percentage of physical RAM (default 90%, tolerance 85–95%). Flags the SQL Server default sentinel value 2147483647 (231−1) as unconfigured.

Module: sqmSQLTool
Requires: dbatools
ShouldProcess: No
Output: PSCustomObject

Execution Flow

START TotalRamMB from Win32_ComputerSystem.TotalPhysicalMemory RecommendedMB = TotalRamMB × RecommendedPct/100 (default 90%) Get-DbaMaxMemory -SqlInstance → CurrentMaxMemMB Current vs. tolerance band [85%RAM .. 95%RAM] or sentinel 2147483647? sentinel → Unconfigured > 95% → TooHigh < 85% → TooLow in band → Status = OK Return PSCustomObject (CurrentMaxMemMB, RecommendedMB, TotalRamMB, Status) DONE
The 85–95% tolerance band avoids flagging every instance that's off by a rounding error from the 90% target. This is a read-only diagnostic, set the value with dbatools' Set-DbaMaxMemory. On instances that share hardware with other SQL instances or services, the 90% default target is too aggressive; use -RecommendedPct to match your actual sizing plan.

Parameters

ParameterTypeRequiredDescription
-SqlInstanceStringRequiredSQL Server instance name, e.g. "MSSQLSERVER" or "SERVER\INST01".
-RecommendedPctInt (70–99)OptionalTarget percentage of physical RAM for SQL Server. Default: 90.

Return Value

Returns a single PSCustomObject with: SqlInstance, CurrentMaxMemMB, RecommendedMB, TotalRamMB, Status (OK, TooHigh, TooLow, Unconfigured, or Error), Message.

Examples

Example 1, Check against the default 90% target

Test-sqmMaxMemory -SqlInstance 'MSSQLSERVER'

Example 2, Show only instances that need adjustment

Test-sqmMaxMemory -SqlInstance 'SQL01\INST1' | Where-Object { $_.Status -ne 'OK' }