Test-DbaTempDbConfig
View SourceSynopsis
Tests tempdb configuration against SQL Server best practices and returns compliance status for each rule.
Description
Performs a comprehensive audit of tempdb configuration against Microsoft’s recommended best practices, returning detailed compliance results for each rule. This saves DBAs from manually checking multiple tempdb settings and provides clear guidance on which configurations need attention.
The function evaluates six critical areas of tempdb configuration:
- TF 1118 enabled - Is Trace Flag 1118 enabled (See KB328551).
- File Count - Does the count of data files in tempdb match the number of logical cores, up to 8?
- File Growth - Are any files set to have percentage growth? Best practice is all files have an explicit growth value.
- File Location - Is tempdb located on the C:? Best practice says to locate it elsewhere.
- File MaxSize Set (optional) - Do any files have a max size value? Max size could cause tempdb problems if it isn’t allowed to grow.
- Data File Size Equal - Are the sizes of all the tempdb data files the same?
Each rule returns the current setting, recommended setting, and whether the configuration follows best practices. This is particularly useful during SQL Server health checks, performance troubleshooting, or compliance audits where tempdb configuration directly impacts system performance.
Syntax
Test-DbaTempDbConfig
[-SqlInstance] <DbaInstanceParameter[]>
[[-SqlCredential] <PSCredential>]
[-EnableException]
[<CommonParameters>]
Examples
Example: 1
PS C:\> Test-DbaTempDbConfig -SqlInstance localhost
Checks tempdb on the localhost machine.
Example: 2
PS C:\> Test-DbaTempDbConfig -SqlInstance localhost | Select-Object *
Checks tempdb on the localhost machine. All rest results are shown.
Example: 3
PS C:\> Get-DbaRegServer -SqlInstance sqlserver2014a | Test-DbaTempDbConfig | Select-Object * | Out-GridView
Checks tempdb configuration for a group of servers from SQL Server Central Management Server (CMS). Output includes all columns. Send output to GridView.
Required Parameters
-SqlInstance
The target SQL Server instance or instances. SQL Server 2005 and higher are supported.
| Property | Value |
|---|---|
| Alias | |
| Required | True |
| Pipeline | true (ByValue) |
| Default Value |
Optional Parameters
-SqlCredential
Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).
Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory - Integrated are all supported.
For MFA support, please use Connect-DbaInstance.
| Property | Value |
|---|---|
| Alias | |
| Required | False |
| Pipeline | false |
| Default Value |
-EnableException
By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with “sea of red” exceptions, but is inconvenient because it basically disables advanced scripting.
Using this switch turns this “nice by default” feature off and enables you to catch exceptions with your own try/catch.
| Property | Value |
|---|---|
| Alias | |
| Required | False |
| Pipeline | false |
| Default Value | False |
Outputs
PSCustomObject
Returns exactly 6 objects per SQL Server instance - one for each tempdb configuration rule evaluated. Each object contains compliance status for a single best practice rule.
Properties (consistent across all 6 rule objects):
- ComputerName: The computer name hosting the SQL Server instance
- InstanceName: The SQL Server instance name
- SqlInstance: The full SQL Server instance name (computer\instance)
- Rule: The name of the configuration rule being evaluated (string):
- “TF 1118 Enabled” - Trace Flag 1118 status for proportional fill algorithm * “File Count” - Number of tempdb data files compared to recommended count * “File Growth in Percent” - Whether any files use percentage-based growth (should be KB-based) * “File Location” - Whether any files are located on C:\ drive * “File MaxSize Set” - Whether any files have maximum size limits set * “Data File Size Equal” - Whether all tempdb data files are equally sized
- Recommended: The recommended value for this rule (bool or int):
- Integer for “File Count” rule (recommended = min(8, processor count)) * Boolean false for “File Growth in Percent”, “File Location”, “File MaxSize Set” * Boolean true for “TF 1118 Enabled” (SQL 2012 and below) or false (SQL 2016+) * Boolean true for “Data File Size Equal”
- CurrentSetting: The actual current value on this instance (bool or int):
- Integer for “File Count” rule (actual count of tempdb data files) * Boolean for all other rules
- IsBestPractice: Boolean indicating whether the current setting meets Microsoft’s best practice recommendations
- Notes: Explanatory text describing the rule and recommendations All properties are accessible using Select-Object *.
dbatools