Thor Logo dbatools

Get-DbaDbccHelp

View Source
Patrick Flynn (@sqllensman)
Windows, Linux, macOS

Synopsis

Retrieves syntax help and parameter information for DBCC commands

Description

Executes DBCC HELP against SQL Server to display syntax, parameters, and usage information for Database Console Commands. This saves you from having to look up DBCC command syntax in documentation, especially for complex commands like CHECKDB, CHECKTABLE, or SHRINKFILE. Supports both documented and undocumented DBCC commands when used with the IncludeUndocumented parameter.

Read more:
- https://docs.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-help-transact-sql

Syntax

Get-DbaDbccHelp
    [-SqlInstance] <DbaInstanceParameter[]>
    [[-SqlCredential] <PSCredential>]
    [[-Statement] <String>]
    [-IncludeUndocumented]
    [-EnableException]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Get-DbaDbccHelp -SqlInstance SQLInstance -Statement FREESYSTEMCACHE -Verbose | Format-List

Runs the command DBCC HELP(FREESYSTEMCACHE) WITH NO_INFOMSGS against the SQLInstance SQL Server instance.

Example: 2
PS C:\> Get-DbaDbccHelp -SqlInstance SQLInstance -Statement WritePage -IncludeUndocumented | Format-List

Sets Trace Flag 2588 on for the session and then runs the command DBCC HELP(WritePage) WITH NO_INFOMSGS against the SQLInstance SQL Server instance.

Required Parameters

-SqlInstance

The target SQL Server instance or instances.

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

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default Value
-Statement

Specifies the DBCC command name to get syntax help for. Provide only the command portion after “DBCC” (e.g., CHECKDB, CHECKTABLE, SHRINKFILE).
Use this when you need to verify command syntax before running maintenance operations or troubleshooting database issues.
Common commands include CHECKDB for database integrity, SHRINKFILE for file management, or FREEPROCCACHE for memory management.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default Value
-IncludeUndocumented

Enables access to help for undocumented DBCC commands by setting trace flag 2588 for the session.
Use this when troubleshooting advanced scenarios that require undocumented commands like WRITEPAGE or PAGE.
Only works on SQL Server 2005 and higher, and should be used with caution as undocumented commands can affect system stability.

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