Created
May 5, 2023 14:06
-
-
Save Ertavf/459954c1f1ba4b3da48657e71776aa01 to your computer and use it in GitHub Desktop.
Create a new firewall rule for each port
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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