< Back

Set-DbaTcpPort

Mon Jan 13, 2020 5:44 pm

NAME Set-DbaTcpPort



SYNOPSIS

Changes the TCP port used by the specified SQL Server.





SYNTAX

Set-DbaTcpPort [-SqlInstance] <Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]> [[-Credential]

<Pscredential>] [-Port] <Int> [[-IpAddress] <System.Net.IPAddress[]>] [-EnableException <Switch>]

[<CommonParameters>]





DESCRIPTION

This function changes the TCP port used by the specified SQL Server.





PARAMETERS

-Credential [<Pscredential>]

Credential object used to connect to the Windows server itself as a different user (like SQL Configuration

Manager)



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-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



-IpAddress [<System.Net.IPAddress[]>]

Which IpAddress should the portchange , if omitted allip (0.0.0.0) will be changed with the new port number.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Port [<Int>]

TCPPort that SQLService should listen on.



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.



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: Service, Port, TCP, Configure

Author: @H0s0n77

Website: https://dbatools.io

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

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



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



PS C:\\>Set-DbaTcpPort -SqlInstance sql2017 -Port 1433



Sets the port number 1433 for all IP Addresses on the default instance on sql2017. Prompts for confirmation.

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



PS C:\\>Set-DbaTcpPort -SqlInstance winserver\\sqlexpress -IpAddress 192.168.1.22 -Port 1433 -Confirm:$false



Sets the port number 1433 for IP 192.168.1.22 on the sqlexpress instance on winserver. Does not prompt for

confirmation.

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



PS C:\\>Set-DbaTcpPort -SqlInstance sql2017, sql2019 -port 1337 -Credential ad\\dba



Sets the port number 1337 for all IP Addresses on SqlInstance sql2017 and sql2019 using the credentials for

ad\\dba. Prompts for confirmation.



RELATED LINKS

https://dbatools.io/Set-DbaTcpPort