Execution Flow
Only data files count toward the comparison, the single TempDB log file is intentionally excluded, since splitting the log provides no benefit (unlike data files, which parallelize allocation across proportional-fill round-robin). Read-only diagnostic; use
Set-sqmServerSetting, T-SQL ALTER DATABASE tempdb ADD FILE, or dbatools to add files.Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| -SqlInstance | String | Optional | SQL Server instance. Default: local computer name. |
| -SqlCredential | PSCredential | Optional | SQL authentication credential for the connection. |
| -MaxFiles | Int (1–64) | Optional | Maximum recommended file count, capping the CPU-based recommendation. Default: 8, or the module config key CheckTempDbMaxFiles 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, CurrentFileCount, RecommendedCount, LogicalCores, Status (OK, Warning, or Error), Message.
Examples
Example 1, Check TempDB file count
Test-sqmTempDbFileCount -SqlInstance "SQL01"Example 2, Cap the recommendation at 4 files
Test-sqmTempDbFileCount -SqlInstance "SQL01\INST1" -MaxFiles 4