How to add, remove and view firewall rules in Windows Powershell?

Add firewall rule

New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22

 

View firewall rule

Get-NetFirewallRule -Name sshd

 

Delete firewall rule

Remove-NetFirewallRule -Name sshd

Leave a Reply