Sunday, November 23, 2014

Powershell and firewalls

Finally with Windows 8.1 and Server 2012 we have some new cmdlets that make managing firewall-rules much easier. Hopefully we can now put netsh to the everlasting rest.

Example script – blockapps.ps1

$rulename = "BlockSomething"
$appPath = "D:\temp\Myprogram.exe"
New-NetFirewallRule -displayname $rulename -Direction Outbound -Program $appPath -action Block

 

References:

http://technet.microsoft.com/en-us/library/jj554908.aspx – cmd syntax

No comments: