Today is a special day for me, it’s my birthday, and I will continue the tradition of giving something to the community on this day (I started this tradition last year)… In the past, I wrote a series of posts describing step-by-step how to install and configure BizTalk Server 2010.
One of these steps is to configure SQL Server Network Protocols, in special ensure that TCP/IP is enabled and Shared Memory is disabled. You can see how to accomplish this using the SQL Server Configuration Manager tool here.
📝 One-Minute Brief
Learn how to automate the configuration of SQL Server Network Protocols for BizTalk Server using PowerShell. This guide explains why protocols like “Shared Memory” can hinder performance and provides a ready-to-use script to disable Shared Memory and VIA while enabling TCP/IP and Named Pipes. It also includes steps to restart necessary SQL and BizTalk services to apply changes.
However, a community member (anonymous) left me a comment asking me whether it was possible to accomplish this (disable shared memory) from the command line or registry, and the answer is: YES, of course, you can, for example, configure all the SQL Server Network Protocols with PowerShell.
All network protocols are installed by SQL Server Setup, but may or may not be enabled. And you need to be aware that these protocols can have an impact on your BizTalk environment, for example:
- Under certain stress conditions (such as clients accessing SQL Server from the same computer), the SQL Server Shared Memory protocol may lower BizTalk Server performance.
- BizTalk Server loses connectivity with a remote SQL Server computer that houses the BizTalk Server databases, and this may happen if the necessary protocols for SQL Server are not enabled.
So normally we need to perform the following configuration:
- Disable the Shared Memory and VIA protocols.
- And enable the TCP/IP and Named Pipes protocols.
How can I configure SQL Server Network Protocols with PowerShell?
This is a simple script to configure SQL Server Network Protocols for SQL Server that houses BizTalk Server databases:
[reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo")
[reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.SqlWmiManagement")
##################################################################
# Function to Enable or Disable a SQL Server Network Protocol
##################################################################
function ChangeSQLProtocolStatus($server,$instance,$protocol,$enable){
$smo = 'Microsoft.SqlServer.Management.Smo.'
$wmi = new-object ($smo + 'Wmi.ManagedComputer')
$singleWmi = $wmi | where {$_.Name -eq $server}
$uri = "ManagedComputer[@Name='$server']/ServerInstance[@Name='$instance']/ServerProtocol[@Name='$protocol']"
$protocol = $singleWmi.GetSmoObject($uri)
$protocol.IsEnabled = $enable
$protocol.Alter()
$protocol
}
##################################################################
# Enable TCP/IP SQL Server Network Protocol
##################################################################
ChangeSQLProtocolStatus -server "BTS2010LAB01" -instance "MSSQLSERVER" -protocol "TCP" -enable $true
##################################################################
# Enable Named Pipes SQL Server Network Protocol
##################################################################
ChangeSQLProtocolStatus -server "BTS2010LAB01" -instance "MSSQLSERVER" -protocol "NP" -enable $true
##################################################################
# Disable Shared Memory SQL Server Network Protocol
##################################################################
ChangeSQLProtocolStatus -server "BTS2010LAB01" -instance "MSSQLSERVER" -protocol "SM" -enable $false
##################################################################
# Disable VIA SQL Server Network Protocol
##################################################################
ChangeSQLProtocolStatus -server "BTS2010LAB01" -instance "MSSQLSERVER" -protocol "VIA" -enable $false
Because after we correctly set up the protocols, we need to restart the SQL services for the changes to take effect, this script also restarts all the services and BizTalk Services if they exist! However, this last part is optional.
$service = get-service "MSSQLSERVER"
restart-service $service.name -force #Restart SQL Services
$service = get-service "ENTSSO" #Start Enterprise Single Sign-On Service
if( $service -ne $null )
{
start-service $service.name
}
get-service BTS* | foreach-object -process {start-service $_.Name} # Start BizTalk Services
Once again, I also like to thank my friend Rui Machado for always wanting and helping in all my small challenges. In this particular sample, Rui was the creator of the function ChangeSQLProtocolStatus 😉
Download
THIS POWERSHELL IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND.
You can download How to set SQL Server Network Protocols in the SQL Server for BizTalk Server Databases with PowerShell from GitHub here:
Hope you find this helpful! If you liked the content or found it useful and would like to support me in writing more, consider buying (or helping to buy) a Star Wars Lego set for my son.
Hi Sandro,
another great article, thanks!
What about different SQL services? Do we have to stop the SQL Server FullText Search?
Hi Leonid, Thanks.
When we force the restart of the MSSQLSERVER he will also restart all SQL services that depend on it and stop all the other dependent services like BizTalk Services and Enterprise Single Sign-On Service