5

#PSTip Adding Firewall rules in Windows 8 and Server 2012

Note: This tip requires PowerShell 3.0 or above.

Before the release of Windows Server 2012 and Windows 8, adding rules to Windows Firewall required a painful approach of using the firewall COM object.

In Windows Server 2012 and Windows 8 operating systems, there is a new cmdlet called New-NetFirewallRule. This cmdlet provides a way to add new firewall rules.

The following example shows how to use this cmdlet to enable inbound traffic to port 80 on the local system.

New-NetFirewallRule -DisplayName "Allow Port 80" -Direction Inbound -LocalPort 80 -Protocol TCP
-Action Allow
Filed in: Columns, Tips and Tricks Tags: , , ,
© 2018 PowerShell Magazine. All rights reserved. XHTML / CSS Valid.
Proudly designed by Theme Junkie.
%d bloggers like this: