Programmatically enabling/disabling SQL Native Client Protocols

SQL Server Configuration Manager uses the WMI provider for Configuration Management. More specifically, it uses the SetEnable/SetDisable methods of the ClientNetworkProtocol class.

The following PowerShell script will leverage that class to enumerate the client protocols and whether they are enabled or not (ProtocolOrder == 0 means disabled):

Get-WmiObject -namespace root\Microsoft\SqlServer\ComputerManagement -class ClientNetworkProtocol | Select-Object ProtocolName, ProtocolDisplayName, ProtocolOrder

And this example, would disable Named Pipes:

(Get-WmiObject -namespace root\Microsoft\SqlServer\ComputerManagement -class ClientNetworkProtocol -filter "ProtocolName='np'").SetDisable()

Notice that you might want to use the ComputerManagement10 namespace instead, if you’re referring to SNAC 10.0.

Also note that there is a separate configuration for each “bitness” of the SQL Server Native Client (x86 vs. x64). So you would have to execute the previous code from %windir%\System32\WindowsPowerShell\v1.0\powershell.exe or from %windir%\SysWOW64\WindowsPowerShell\v1.0\powershell.exe depending on which bitness you are targeting.