通过Python使用Powershell的防火墙规则

时间:2020-04-25 08:26:31

标签: python powershell firewall

所以我试图制作一个脚本来阻止防火墙上的特定IP。

我发现Powershell命令是:

New-NetFirewallRule -DisplayName "Name of Scope" -Direction Outbound –LocalPort Any -Protocol TCP -Action Block -RemoteAddress 11.11.11.11/32

现在我不确定该shell命令是否正确,但这正是我所发现的。

现在要通过python执行powershell命令,我读到我需要使用os.system()subprocess.Popen

由于我尝试的方法无效,请问有人愿意告诉我如何执行此任务。

0 个答案:

没有答案