dbatools is a free PowerShell module with over 300 SQL Server administration, best practice and migration commands included.

Please note that documentation and command names may be out of date while we work furiously towards 1.0


Returns Trace Flags that are enabled globally on each instance(s) of SQL Server as an object.


dbatools - Get-DbaTraceFlag


Returns all Trace Flag information on the local default SQL Server instance.

Get-DbaTraceFlag -SqlInstance localhost

Returns all Trace Flag(s) for the local and sql2016 SQL Server instances.

Get-DbaTraceFlag -SqlInstance localhost, sql2016

Returns Trace Flag status for TF 4199 and 3205 for the local SQL Server instance if they are enabled.

Get-DbaTraceFlag -SqlInstance localhost -TraceFlag 4199,3205


This command was created by Kevin Bullen. You can find Kevin on Twitter.


From PowerShell, execute Get-Help Get-DbaTraceFlag -Detailed for more information on this function.

Source Code

Want to see the source code? View Get-DbaTraceFlag.ps1 on GitHub

Related commands