How to find SQL Server running port?

后端 未结 13 739
再見小時候
再見小時候 2020-11-28 20:10

Yes I read this How to find the port for MS SQL Server 2008?

no luck.

telnet 1433

returns connection failed, so I must s

13条回答
  •  忘掉有多难
    2020-11-28 20:30

    Perhaps not the best options but just another way is to read the Windows Registry in the host machine, on elevated PowerShell prompt you can do something like this:

    #Get SQL instance's Port number using Windows Registry:
    $instName = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server').InstalledInstances[0]
    $tcpPort = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\$instName\MSSQLServer\SuperSocketNetLib\Tcp").TcpPort
    Write-Host The SQL Instance:  `"$instName`"  is listening on `"$tcpPort`"  "TcpPort."
    

    Ensure to run this PowerShell script in the Host Server (that hosts your SQL instance / SQL Server installation), which means you have to first RDP into the SQL Server/Box/VM, then run this code.

    HTH

提交回复
热议问题