Thor Logo dbatools

Disable-DbaTraceFlag

View Source
Garry Bargsley (@gbargsley), blog.garrybargsley.com
Windows, Linux, macOS

Synopsis

Disables globally running trace flags on SQL Server instances

Description

Turns off trace flags that are currently enabled globally across SQL Server instances using DBCC TRACEOFF.
Useful when you need to disable diagnostic trace flags that were enabled for troubleshooting or testing without requiring a restart.
Only affects flags currently running in memory - does not modify startup parameters or persistent trace flag settings.
Use Set-DbaStartupParameter to manage trace flags that persist after restarts.

Syntax

Disable-DbaTraceFlag
    [-SqlInstance] <DbaInstanceParameter[]>
    [[-SqlCredential] <PSCredential>]
    [-TraceFlag] <Int32[]>
    [-EnableException]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Disable-DbaTraceFlag -SqlInstance sql2016 -TraceFlag 3226

Disable the globally running trace flag 3226 on SQL Server instance sql2016

Required Parameters

-SqlInstance

The target SQL Server instance or instances.

PropertyValue
Alias
RequiredTrue
Pipelinetrue (ByValue)
Default Value
-TraceFlag

Specifies the trace flag numbers to disable globally across all sessions on the SQL Server instance.
Only trace flags that are currently running will be disabled - flags not currently active are skipped with a warning.
Supports multiple trace flag numbers to disable several flags in a single operation.

PropertyValue
Alias
RequiredTrue
Pipelinefalse
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.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
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.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default ValueFalse
-WhatIf

Shows what would happen if the command were to run. No actions are actually performed.

PropertyValue
Aliaswi
RequiredFalse
Pipelinefalse
Default Value
-Confirm

Prompts you for confirmation before executing any changing operations within the command.

PropertyValue
Aliascf
RequiredFalse
Pipelinefalse
Default Value