Programmatically modify Firewall rules in Windows Server 2008 R2

假装没事ソ 提交于 2020-01-04 09:07:48

问题


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?


回答1:


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.




回答2:


There's also using COM:

$fw=new-object -com hnetcfg.fwmgr


来源:https://stackoverflow.com/questions/2231688/programmatically-modify-firewall-rules-in-windows-server-2008-r2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!