自动打开命名管道和tcp \ ip

编程入门 行业动态 更新时间:2024-10-24 14:26:57
本文介绍了自动打开命名管道和tcp \ ip的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在安装需要修改SQL Server的新产品.

I am working on an install of a new product that requires modifications to SQL Server.

具体来说,启用tcp/ip并打开命名管道.我知道如何手动进行.我想要的是一种通过SQL或C#代码为新客户自动执行此操作的方法.

Specifically, enable tcp/ip and turning on named pipes. I know how to do it manually. What i want is a way to automate this for a new customer though SQL or with C# code.

我希望为正确的方向提供任何建议.

I would love any suggestions for the right direction.

推荐答案

您可以使用C#和服务器管理对象(SMO)来做到这一点.您需要的类在Microsoft.SqlServer.Smo和Microsoft.SqlServer.WmiManagement库中.

You can use C# and Server Management Objects (SMO) to do it. The classes you need are in the Microsoft.SqlServer.Smo and Microsoft.SqlServer.WmiManagement libraries.

这是我使用过的Powershell代码段,它使用了相同的对象.希望它会指出正确的方向.

Here's a Powershell snippet I've used that uses the same objects. Hopefully, it will point you down the right path.

$smo = 'Microsoft.SqlServer.Management.Smo.' $wmi = new-object ($smo + 'Wmi.ManagedComputer'). # List the object properties, including the instance names. $Wmi # Enable the TCP protocol on the default instance. $uri = "ManagedComputer[@Name='<computer_name>']/ ServerInstance[@Name='MSSQLSERVER']/ServerProtocol[@Name='Tcp']" $Tcp = $wmi.GetSmoObject($uri) $Tcp.IsEnabled = $true $Tcp.Alter() $Tcp # Enable the named pipes protocol for the default instance. $uri = "ManagedComputer[@Name='<computer_name>']/ ServerInstance[@Name='MSSQLSERVER']/ServerProtocol[@Name='Np']" $Np = $wmi.GetSmoObject($uri) $Np.IsEnabled = $true $Np.Alter() $Np

更多推荐

自动打开命名管道和tcp \ ip

本文发布于:2023-11-05 04:53:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1559955.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:管道   tcp   ip

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!