commands

^

Set-DbaNetworkConfiguration

Author Andreas Jordan (@JordanOrdix), ordix.de
Availability Windows only

 

Synopsis

Sets the network configuration of a SQL Server instance.

Description

Sets the network configuration of a SQL Server instance.

Parameters are available for typical tasks like enabling or disabling a protocol or switching between dynamic and static ports. The object returned by Get-DbaNetworkConfiguration can be used to adjust settings of the properties and then passed to this command via pipeline or -InputObject parameter.

A change to the network configuration with SQL Server requires a restart to take effect, support for this can be done via the RestartService parameter.

Remote SQL WMI is used by default, with PS Remoting used as a fallback.

For a detailed explanation of the different properties see the documentation at: https://docs.microsoft.com/en-us/sql/tools/configuration-manager/sql-server-network-configuration

Syntax

Set-DbaNetworkConfiguration
    [-SqlInstance] <DbaInstanceParameter[]>
    [-Credential <PSCredential>]
    [-EnableProtocol <String>]
    [-DisableProtocol <String>]
    [-DynamicPortForIPAll]
    [-StaticPortForIPAll <Int32[]>]
    [-RestartService]
    [-EnableException]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Set-DbaNetworkConfiguration
    [-Credential <PSCredential>]
    [-RestartService] -InputObject <Object[]>
    [-EnableException]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Set-DbaNetworkConfiguration -SqlInstance sql2016 -EnableProtocol SharedMemory -RestartService

Ensures that the shared memory network protocol for the default instance on sql2016 is enabled.
Restarts the service if needed.

Example: 2
PS C:\> Set-DbaNetworkConfiguration -SqlInstance sql2016\test -StaticPortForIPAll 14331, 14332 -RestartService

Ensures that the TCP/IP network protocol is enabled and configured to use the ports 14331 and 14332 for all IP addresses.
Restarts the service if needed.

Example: 3
PS C:\> $netConf = Get-DbaNetworkConfiguration -SqlInstance sqlserver2014a
PS C:\> $netConf.TcpIpProperties.KeepAlive = 60000
PS C:\> $netConf | Set-DbaNetworkConfiguration -RestartService -Confirm:$false

Changes the value of the KeepAlive property for the default instance on sqlserver2014a and restarts the service.
Does not prompt for confirmation.

Required Parameters

-SqlInstance

The target SQL Server instance or instances.

Alias
Required True
Pipeline false
Default Value
-InputObject

The output object from Get-DbaNetworkConfiguration. Get-DbaNetworkConfiguration has to be run with -OutputType Full (default) to get the complete object.

Alias
Required True
Pipeline true (ByValue)
Default Value

Optional Parameters

-Credential

Credential object used to connect to the Computer as a different user.

Alias
Required False
Pipeline false
Default Value
-EnableProtocol

Enables one of the following network protocols: SharedMemory, NamedPipes, TcpIp.

Alias
Required False
Pipeline false
Default Value
Accepted Values SharedMemory,NamedPipes,TcpIp
-DisableProtocol

Disables one of the following network protocols: SharedMemory, NamedPipes, TcpIp.

Alias
Required False
Pipeline false
Default Value
Accepted Values SharedMemory,NamedPipes,TcpIp
-DynamicPortForIPAll

Configures the instance to listen on a dynamic port for all IP addresses. Will enable the TCP/IP protocol if needed. Will set TcpIpProperties.ListenAll to $true if needed. Will reset the last used dynamic port if already set.

Alias
Required False
Pipeline false
Default Value False
-StaticPortForIPAll

Configures the instance to listen on one or more static ports for all IP addresses. Will enable the TCP/IP protocol if needed. Will set TcpIpProperties.ListenAll to $true if needed.

Alias
Required False
Pipeline false
Default Value
-RestartService

Every change to the network configuration needs a service restart to take effect. This switch will force a restart of the service if the network configuration has changed.

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

 

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