How to find the port where SQL server is listning using PowerShell

Here is the PowerShell code snippet to find the port where the SQL server is listing:

 

$SQLPort = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\$InstanceName\MSSQLServer\SuperSocketNetLib\Tcp").TcpPort
Write-Host "The SQl Server TCP/IP port is $SQLPort"


# HostPort is for the XML config files of Tomcat
$HostPort = $env:computername+':'+$SQlPort

Advertisements
This entry was posted in Scripts and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s