Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change SQL Server Instance TCP Ports to 1433 using CMD?

I'm thinking if it possible to change SQL Server 2008 Instance TCP Ports to 1433 using cmd and without using SQL Server Configuration Manager.

I just want to apply this to my application setup, My client wants it to be in multi-user mode.

I know how to enable TCP/IP using cmd. And I know how to create a script to allow a specific port in windows firewall.

Thanks in advance. Please leave a comment if my details are not enough to answer my question.

like image 900
user3579618 Avatar asked Oct 14 '25 06:10

user3579618


1 Answers

Not quite cmd, but powershell is the new cmd. :)

import-module sqlps;
$MachineObject = new-object ('Microsoft.SqlServer.Management.Smo.WMI.ManagedComputer') "computername"
$instance = $MachineObject.getSmoObject(
   "ManagedComputer[@Name='computername']/" + 
   "ServerInstance[@Name='instancename']"
)

$instance.ServerProtocols['Tcp'].IPAddresses['IPAll'].IPAddressProperties['TcpPort'].Value = "1433"
$instance.ServerProtocols['Tcp'].IPAddresses['IPAll'].IPAddressProperties['TcpDynamicPorts'].Value = ""
$instance.ServerProtocols['Tcp'].Alter()
like image 130
Ben Thul Avatar answered Oct 16 '25 21:10

Ben Thul



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!