BAT SCRIPT TO OPEN SQL SERVER PORTS IN THE FIREWALL


rem ******************code start******************************
 
@echo off 
sc config MpsSvc start= demand 
sc start MpsSvc
 
echo. *** OPENING SQL SERVER PORTS IN THE FIREWALL *** 
echo. source Mohamed Riyaz.
echo. 
echo. Note for Named Instances – SQL mirroring – Dynamic Ports and the firewall 
echo. see http://msdn.microsoft.com/en-us/library/cc646023(v=SQL.100).aspx#BKMK_programs 
echo. You will need to open firewall ports for your mirroring endpoints and possibly dynamic ports 
echo. 
echo. 
echo. Opening SQL Server TCP 1433 
netsh advfirewall firewall add rule name=”SQL Server (TCP 1432)” dir=in action=allow protocol=TCP localport=1433 profile=domain 
echo. 
echo. Opening SQL Admin Connection TCP 1434 
netsh advfirewall firewall add rule name=”SQL Admin Connection (TCP 1434)” dir=in action=allow protocol=TCP localport=1434 profile=domain 
echo. 
echo. Opening SQL Service Broker TCP 4022 
netsh advfirewall firewall add rule name=”SQL Service Broker (TCP 4022)” dir=in action=allow protocol=TCP localport=4022 profile=domain 
echo. 
echo. Port 135 
netsh advfirewall firewall add rule name=”SQL Debugger/RPC (TCP 135)” dir=in action=allow protocol=TCP localport=135 profile=domain 
echo. 
echo. Opening SQL Browser UDP 1434 
netsh advfirewall firewall add rule name=”SQL Browser (UDP 1434)” dir=in action=allow protocol=UDP localport=1434 profile=domain 
echo. 
echo. Opening Analysis Services TCP 2383 
netsh advfirewall firewall add rule name=”Analysis Services (TCP 2383)” dir=in action=allow protocol=TCP localport=2383 profile=domain 
echo. 
echo. Opening SQL Browser TCP 2382 
netsh advfirewall firewall add rule name=”SQL Browser (TCP 2382)” dir=in action=allow protocol=TCP localport=2382 profile=domain 
echo. 
echo. ***Done ***
 
sc stop MpsSvc 
sc config MpsSvc start= disabled
 
rem ******************code end******************************

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.