Tuesday, April 19, 2016

Script to open ports for SQL Server

For years now, I've been using a netsh batch script to manage SQL Server firewall ports (see below). I recall picking this up on MSDN (How to open firewall ports for SQL Server).

All well and good, but Windows has moved to PowerShell, and it's time to upgrade.  Fortunately, Ryan Mangan has created a PowerShell script to replace the old netsh script.  You can find it here: PowerShell Script for SQL Firewall rules - Ryan Mangan. And another one at Scripts to open Windows Firewall Ports for SQL Server - brankovucinec.com.

For reference, here is an older copy of the port change script using the netsh commands - which still works:

       

@echo =========  SQL Server Ports  ===================
@echo Source:
@echo   http://support.microsoft.com/kb/968872
@echo ================================================  
@echo Enabling SQLServer default instance port 1433
netsh firewall set portopening TCP 1433 "SQLServer" 
@echo Enabling Dedicated Admin Connection port 1434
netsh firewall set portopening TCP 1434 "SQL Admin Connection" 
@echo Enabling conventional SQL Server Service Broker port 4022  
netsh firewall set portopening TCP 4022 "SQL Service Broker" 
@echo Enabling Transact-SQL Debugger/RPC port 135 
netsh firewall set portopening TCP 135 "SQL Debugger/RPC" 
@echo =========  Analysis Services Ports  ==============
@echo Enabling SSAS Default Instance port 2383
netsh firewall set portopening TCP 2383 "Analysis Services" 
@echo Enabling SQL Server Browser Service port 2382
netsh firewall set portopening TCP 2382 "SQL Browser" 
@echo =========  Misc Applications  ==============
@echo Enabling HTTP port 80 
netsh firewall set portopening TCP 80 "HTTP" 
@echo Enabling SSL port 443
netsh firewall set portopening TCP 443 "SSL" 
@echo Enabling HTTP port 300 Master Data Services 
netsh firewall set portopening TCP 300 "HTTP" 
@echo Enabling port for SQL Server Browser Service's 'Browse' Button
netsh firewall set portopening UDP 1434 "SQL Browser" 
@echo Allowing multicast broadcast response on UDP (Browser Service Enumerations OK)
netsh firewall set multicastbroadcastresponse ENABLE 

-- for tabular on Windows10, based on error message back usingSSMS
netsh firewall set portopening TCP 50523 "Analysis TAb Services" 
       
 

No comments: