0

So I am trying to make a script that blocks a specific IP on my firewall.

I found that the Powershell command is:

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

Now I'm not sure if that shell command is good or not but It's just what I found.

Now to execute a powershell command through python I read that I need to use either os.system() or subprocess.Popen.

Would anyone be kind enough to tell me how to perform this task please since what I tried didn't work.

rdas
  • 20,604
  • 6
  • 33
  • 46
  • As aside, the `–` for parameter `LocalPort` looks like an [EM DASH](https://www.w3schools.com/charsets/ref_utf_punctuation.asp). Replace that by a normal dash `-` – Theo Apr 25 '20 at 09:36
  • Does this answer your question? [How to run windows-powershell commands from python?](https://stackoverflow.com/questions/54338990/how-to-run-windows-powershell-commands-from-python) – RoadRunner Apr 25 '20 at 09:43

0 Answers0