[sourcecode language=”powershell”]
#Function to get SQL Server network protocols
Function Get-SQLProtocols
{
Param([String]$ComputerName = $env:COMPUTERNAME)
[reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") | out-null
$Server = New-Object "Microsoft.SqlServer.Management.Smo.Server" $ComputerName
$VersionMajor = $Server.VersionMajor
Get-WmiObject -ComputerName $ComputerName -NameSpace root\Microsoft\SqlServer\ComputerManagement$VersionMajor -Class ClientNetworkProtocol | Select-Object ProtocolName, ProtocolDisplayName, ProtocolOrder
}#End of function
[/sourcecode]
The output of the above function usually looks like this:
ProtocolName | ProtocolDisplayName | ProtocolOrder |
---|---|---|
sm |
Shared Memory |
1 |
tcp |
TCP/IP |
2 |
np |
Named Pipes |
3 |
via |
VIA |
0 |
Number ‘0’ means corresponding protocol is ‘disabled’, while the NO. ‘1’ has the highest priority to be applied when a DB connection is being established.
Leave a Reply