< Back

Set-DbaSpConfigure

Mon Jan 13, 2020 5:42 pm

NAME Set-DbaSpConfigure



SYNOPSIS

Changes the server level system configuration (sys.configuration/sp_configure) value for a given configuration





SYNTAX

Set-DbaSpConfigure [[-SqlInstance] <Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>] [[-SqlCredential]

<Pscredential>] [[-Value] <Int>] [[-Name] <System.String[]>] [[-InputObject] <System.Object[]>] [-EnableException

<Switch>] [<CommonParameters>]





DESCRIPTION

This function changes the configured value for sp_configure settings. If the setting is dynamic this setting will

be used, otherwise the user will be warned that a restart of SQL is required.



This is designed to be safe and will not allow for configurations to be set outside of the defined configuration

min and max values.



While it is possible to set below the min, or above the max this can cause serious problems with SQL Server

(including startup failures), and so is not permitted.





PARAMETERS

-EnableException [<Switch>]

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.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-InputObject [<System.Object[]>]

Piped objects from Get-DbaSpConfigure



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Name [<System.String[]>]

The name of the configuration to be set -- Configs is auto-populated for tabbing convenience.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SqlCredential [<Pscredential>]

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.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SqlInstance [<Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>]

The target SQL Server instance or instances. This can be a

collection and receive pipeline input



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Value [<Int>]

The new value for the configuration



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



NOTES





Tags: SpConfigure

Author: Nic Cain, https://sirsql.net/



Website: https://dbatools.io

Copyright: (c) 2018 by dbatools, licensed under MIT

License: MIT https://opensource.org/licenses/MIT



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Set-DbaSpConfigure -SqlInstance localhost -Name ScanForStartupProcedures -Value 1



Adjusts the Scan for startup stored procedures configuration value to 1 and notifies the user that this requires a

SQL restart to take effect

-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Get-DbaSpConfigure -SqlInstance sql2017, sql2014 -Name XPCmdShellEnabled, IsSqlClrEnabled |

Set-DbaSpConfigure -Value $false



Sets the values for XPCmdShellEnabled and IsSqlClrEnabled on sql2017 and sql2014 to False

-------------------------- EXAMPLE 3 --------------------------



PS C:\\>Set-DbaSpConfigure -SqlInstance localhost -Name XPCmdShellEnabled -Value 1



Adjusts the xp_cmdshell configuration value to 1.

-------------------------- EXAMPLE 4 --------------------------



PS C:\\>Set-DbaSpConfigure -SqlInstance localhost -Name XPCmdShellEnabled -Value 1 -WhatIf



Returns information on the action that would be performed. No actual change will be made.



RELATED LINKS

https://dbatools.io/Set-DbaSpConfigure