我试图通过使用PowerShell命令来控制Windows Server 2012(R2)防火墙(请参阅https://technet.microsoft.com/en-us/library/hh831755.aspx#BKMK_ProfileGlobalDefaults例如和参考)。
在我的Linux机器上,我能够使用conntrack IPTables的连接状态,以便能够build立和相关的连接( http://www.iptables.info/en/connection-state.html )。 我还没有在Windows防火墙中find相应的东西。
有没有办法在Windows Server使用PowerShell做到这一点? 我在互联网上search,没有发现任何相关的。
您可以使用Windows中的netstat命令查询活动的TCP连接,侦听端口,进程等。
https://technet.microsoft.com/en-us/library/ff961504.aspx
对于您的脚本,您可以将netstat与某些PowerShell结合使用,进行过滤和parsing,并构build防火墙命令。 例如,此脚本使用netstat命令并将其扩展为提供进程名称和筛选。
https://gallery.technet.microsoft.com/scriptcenter/Get-NetworkStatistics-66057d71