views:

322

answers:

2

I want be able to programmatically enable, disable, create firewall rules in Windows Server 2008 R2. What is the object model to modify the firewall rules from .Net/PowerShell?

A: 

There is probably a WMI set of classes for this but I wanted to point out that you can use the existing command line utility netsh.exe from PowerShell. Execute:

netsh firewall /?

To see its options.

Keith Hill
Nope, I've never seen a WMI API, but I've been wrong (many) times before.
Marco Shaw
Wow and I thought WMI supported everything including the kitchen sink. :-)
Keith Hill
A: 

There's also using COM:

$fw=new-object -com hnetcfg.fwmgr
Marco Shaw