commands

^

Set-DbaErrorLogConfig

Author Shawn Melton (@wsmelton), wsmelton.github.com
Availability Windows, Linux, macOS

 

Want to see the source code for this command? Check out Set-DbaErrorLogConfig on GitHub.
Want to see the Bill Of Health for this command? Check out Set-DbaErrorLogConfig.

Synopsis

Set the configuration for the ErrorLog on a given SQL Server instance

Description

Sets the number of log files configured on all versions, and size in KB in SQL Server 2012+ and above.

To set the Path to the ErrorLog, use Set-DbaStartupParameter -ErrorLog. Note that this command requires
remote, administrative access to the Windows/WMI server, similar to SQL Configuration Manager.

Syntax

Set-DbaErrorLogConfig
    [-SqlInstance] <DbaInstanceParameter[]>
    [[-SqlCredential] <PSCredential>]
    [[-LogCount] <Int32>]
    [[-LogSize] <Int32>]
    [-EnableException]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Set-DbaErrorLogConfig -SqlInstance sql2017,sql2014 -LogCount 25

Sets the number of error log files to 25 on sql2017 and sql2014

Example: 2
PS C:\> Set-DbaErrorLogConfig -SqlInstance sql2014 -LogSize 102400

Sets the size of the error log file, before it rolls over, to 102400 KB (100 MB) on sql2014

Example: 3
PS C:\> Set-DbaErrorLogConfig -SqlInstance sql2012 -LogCount 25 -LogSize 500

Sets the number of error log files to 25 and size before it will roll over to 500 KB on sql2012

Required Parameters

-SqlInstance

The target SQL Server instance or instances

Alias
Required True
Pipeline true (ByPropertyName)
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.

Alias
Required False
Pipeline false
Default Value
-LogCount

Integer value between 6 and 99 for setting the number of error log files to keep for SQL Server instance.

Alias
Required False
Pipeline false
Default Value 0
-LogSize

Integer value for the size in KB that you want the error log file to grow. This is feature only in SQL Server 2012 and higher. When the file reaches that limit SQL Server will roll the error log over.

Alias
Required False
Pipeline false
Default Value 0
-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.

Alias
Required False
Pipeline false
Default Value False
-WhatIf

If this switch is enabled, no actions are performed but informational messages will be displayed that explain what would happen if the command were to run.

Alias wi
Required False
Pipeline false
Default Value
-Confirm

If this switch is enabled, you will be prompted for confirmation before executing any operations that change state.

Alias cf
Required False
Pipeline false
Default Value