Skip to content
Windowsfirewall

Windowsfirewall

Windows Firewall Rules

Create windows firewall rule in PS:

1
New-NetFirewallRule -DisplayName "rule name" -Direction Inbound -LocalPort 80,443 -Protocol TCP -Action Allow

Check the enabled profile and the default settings:

1
Get-NetFirewallProfile | Select-Object Name, Enabled, DefaultInboundAction, DefaultOutboundAction | Format-Table -AutoSize

Find firewall rules by port number:

1
Get-NetFirewallPortFilter | Where-Object { $_.LocalPort -eq  } | Get-NetFirewallRule

Enable File and Printer sharing

Enable file and printer sharing in windows firewall

1
Set-NetFirewallRule -DisplayGroup "File And Printer Sharing" -Enabled True -Profile Domain

Enable ICMP ( ping )

1
2
3
4
5
#IPv4
netsh advfirewall firewall add rule name="ICMP Allow incoming V4 echo request" protocol="icmpv4:8,any" dir=in action=allow

#IPv6
netsh advfirewall firewall add rule name="ICMP Allow incoming V6 echo request" protocol="icmpv6:8,any" dir=in action=allow