Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

block ip address windows firewall using powershell from text file

@echo off
if "%1"=="list" (
  netsh advfirewall firewall show rule Blockit | findstr RemoteIP
  exit/b
)

:: Deleting existing block on ips
netsh advfirewall firewall delete rule name="Blockit"

:: Block new ips (while reading them from blockit.txt)
for /f %%i in (blockit.txt) do (
  netsh advfirewall firewall add rule name="Blockit" protocol=any dir=in action=block remoteip=%%i
  netsh advfirewall firewall add rule name="Blockit" protocol=any dir=out action=block remoteip=%%i
)

:: call this batch again with list to show the blocked IPs
call %0 list
Comment

PREVIOUS NEXT
Code Example
Shell :: bluetooth turned off even if switched on 
Shell :: how to change the terminal start in directory 
Shell :: kali linux no_pubkey 67ece5605bcf1346 
Shell :: How to translate to md5 bash 
Shell :: bash script to replace hyphen with underscore 
Shell :: select an object based a field which is like a string jq 
Shell :: playit linux install 
Shell :: onefetch install 
Shell :: Collaborators access SSH new project Github 
Shell :: auto git script 
Shell :: linux compress current directory 
Shell :: pull environment variables with helm charts 
Shell :: set nat in mikrotik 
Shell :: create fake json from console 
Shell :: concatenate two commands powershell 
Shell :: more wsl2 images 
Shell :: ubuntu disable mouse click on release 
Shell :: How can I use Windows PowerShell to find the status of Hyper-V on my laptop running Windows 8.1? 
Shell :: rar command line split size 
Shell :: remove last command from history 
Shell :: conda install nose2 
Shell :: install --jet with or without composer 
Shell :: xfce ubuntu server disable suspend 
Shell :: search in github repo 
Shell :: the operation was rejected by your operating system npm install 
Shell :: bash $! command 
Shell :: pnpm upgrade 
Shell :: sed add line to file 
Shell :: replace main with another branch 
Shell :: swap ctrl and caps lock linux 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =