Database (MSSQL)
TCP 1433, 135, 1434, UDP 1434
Script below require elevated PowerShell
New-NetFirewallRule -DisplayName "SQL Default Port" -Direction Inbound -Group "MSSQL" -Protocol TCP –LocalPort 1433 -Action Allow
New-NetFirewallRule -DisplayName "SQL T-SQL Debugger" -Direction Inbound -Group "MSSQL" -Protocol TCP -LocalPort 135 -Action Allow
New-NetFirewallRule -DisplayName "SQL Browser (TCP)" -Direction Inbound -Group "MSSQL" -Protocol TCP -LocalPort 1434 -Action Allow
New-NetFirewallRule -DisplayName "SQL Browser (UDP)" -Direction Inbound -Group "MSSQL" -Protocol UDP -LocalPort 1434 -Action Allow
Remote Desktop
TCP 3389
Enable
Script below enable RDP capability and enable existing RDP firewall rule
# Enable RDP
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -name "fDenyTSConnections" -value 0
# Enable Firewall
Enable-NetFirewallRule -DisplayGroup "Remote Desktop"
Disable
Script below disable RDP capability and enable existing RDP firewall rule
# Disable RDP
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -name "fDenyTSConnections" -value 1
# Disable Firewall
Disable-NetFirewallRule -DisplayGroup "Remote Desktop"