Create a New Firewall Rule with PowerShell
Create a New Firewall Rule with PowerShell
Create a New Firewall Rule with PowerShell
This is a short post to share a PowerShell script that will create a new Windows Firewall Rule on a local computer.
PowerShell Create New Firewall Rule
We have to ensure that we run PowerShell as Administrator for this to work.
# New firewall rule (run powershell as administrator) if (-not( Get-NetFirewallRule -DisplayName “Allow Inbound SQL (1433)” -ErrorAction SilentlyContinue)) { New-NetFirewallRule ` -DisplayName “Allow Inbound SQL - 1433” ` -Direction Inbound ` -Protocol TCP ` -LocalPort 1433 ` -Action Allow }
The above is creating a new firewall rule so incoming SQL Server (1433) traffic is allowed to happen on this computer.
Other similar/useful posts I have on this include the following:
# How to Check Windows Firewall Status with PowerShell
# How to Enable Windows Firewall with PowerShell
# How to Disable Windows Firewall with PowerShell
0 Comments