Set‑SqlDscConfigurationOption - dsccommunity/SqlServerDsc GitHub Wiki

SYNOPSIS

Set server configuration option value.

SYNTAX

Set-SqlDscConfigurationOption [-ServerObject] <Server> [-Name] <String> [-Value] <Int32> [-Force]
 [-WhatIf] [-Confirm] [<CommonParameters>]

DESCRIPTION

This command sets the value of a SQL Server Database Engine configuration option using SQL Server Management Objects (SMO). The function validates that the option exists and that the provided value is within the option's minimum and maximum range.

EXAMPLES

EXAMPLE 1

$serverObject = Connect-SqlDscDatabaseEngine -InstanceName 'MyInstance'
$serverObject | Set-SqlDscConfigurationOption -Name "Agent XPs" -Value 1

Sets the "Agent XPs" configuration option to enabled (1).

EXAMPLE 2

$serverObject = Connect-SqlDscDatabaseEngine -InstanceName 'MyInstance'
Set-SqlDscConfigurationOption -ServerObject $serverObject -Name "cost threshold for parallelism" -Value 50

Sets the "cost threshold for parallelism" configuration option to 50.

EXAMPLE 3

$serverObject = Connect-SqlDscDatabaseEngine -InstanceName 'MyInstance'
$serverObject | Set-SqlDscConfigurationOption -Name "max degree of parallelism" -Value 4 -WhatIf

Shows what would happen if the "max degree of parallelism" option was set to 4, without actually making the change.

EXAMPLE 4

$serverObject = Connect-SqlDscDatabaseEngine -InstanceName 'MyInstance'
$serverObject | Set-SqlDscConfigurationOption -Name "cost threshold for parallelism" -Value 25 -Force

Sets the "cost threshold for parallelism" configuration option to 25 without prompting for confirmation.

PARAMETERS

-Force

Suppresses prompts and overrides restrictions that would normally prevent the command from completing. When specified, the command will not prompt for confirmation before making changes.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Name

Specifies the name of the configuration option to set.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ServerObject

Specifies current server connection object.

Type: Server
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False

-Value

Specifies the value to set for the configuration option.

Type: Int32
Parameter Sets: (All)
Aliases:

Required: True
Position: 3
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

Microsoft.SqlServer.Management.Smo.Server

SQL Server Management Objects (SMO) Server object representing a SQL Server instance.

OUTPUTS

None.

NOTES

This function supports ShouldProcess, allowing the use of -WhatIf and -Confirm parameters.

RELATED LINKS

⚠️ **GitHub.com Fallback** ⚠️