开发者

How to configure SQL Native Client with powershell?

I have been tasked to write开发者_StackOverflow社区 a script that will enable tcp and named pipes protocols for SQL Server 2008 Express R2 instance. I have found out how to enable these protocols for the SQL Server instance itself, but I haven't found any way to control the SQL Native Client from powershell.

My script is part of an installer, and the code I am installing expects these protocols to be enabled.

Thanks


[reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.SqlWmiManagement")
$wmi = new-object ("Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer") "$env:computername"
$wmi.ServerInstances["SQLEXPRESS"].ServerProtocols["Tcp"].IsEnabled = $true
$wmi.ServerInstances["SQLEXPRESS"].ServerProtocols["Np"].IsEnabled = $true
$wmi.ClientProtocols["tcp"].IsEnabled = $true
$wmi.ClientProtocols["np"].IsEnabled = $true


I finally found the solution. The protocols can be enabled by setting a registry key:

in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Client\SNI10.0, set the ProtocolOrder key to contain the protocols that should be enabled:

sm = Shared memory
np = Named pipes
tcp = TCP (he)
via = Via

Protocols not listed in this key will be disabled.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜