[powershell] block application in firewall
#using script: run <scriptname.ps1> -appname <the application name you want to block>
param ([string]$appname)
$ErrorActionPreference = "SilentlyContinue"
$progfiles86 = (Get-ChildItem "C:\Program Files (x86)" -Recurse).fullname |Select-String -Pattern "$appname.exe"
$progfiles = (Get-ChildItem "C:\Program Files" -Recurse).fullname |Select-String -Pattern "$appname.exe"
if($progfiles86 = $null){$prog = $progfiles} else {$prog = $progfiles}
#(Allow app)
#netsh advfirewall firewall add rule name=$appname dir=in action=allow program=$prog enable=yes
#(Block app)
netsh advfirewall firewall add rule name=$appname dir=in action=block program=$prog enable=yes
/image%2F0881799%2F20140610%2Fob_a8c7fe_logo2.jpg)
Commenter cet article