我正在考虑是否可以使用 cmd 将 SQL Server 2008 实例 TCP 端口更改为 1433,而无需使用 SQL Server 配置管理器。
我只想将此应用到我的应用程序设置中,我的客户希望它处于多用户模式。
我知道如何使用 cmd 启用 TCP/IP。而且我知道如何创建脚本以允许 Windows 防火墙中的特定端口。
提前致谢。如果我的详细信息不足以回答我的问题,请发表评论。
最佳答案
不完全是 cmd,但 powershell 是新的 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()
关于sql-server - 如何使用 CMD 将 SQL Server 实例 TCP 端口更改为 1433?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29190173/