Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Ertavf/459954c1f1ba4b3da48657e71776aa01 to your computer and use it in GitHub Desktop.
Save Ertavf/459954c1f1ba4b3da48657e71776aa01 to your computer and use it in GitHub Desktop.
Create a new firewall rule for each port
# Define the ports to open
$ports = @(5432)
# Create a new firewall rule for each port
foreach ($port in $ports) {
$rule = New-NetFirewallRule -DisplayName "Port $port" -Direction Inbound -Protocol TCP -LocalPort $port -Action Allow
Write-Host "Created firewall rule for port $port"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment