Question: I have been tasked to write 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

Answer: 
```
[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.