Skip to content

asheroto/BlockFolderWindowsFirewall

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 

Repository files navigation

PowerShell Gallery Downloads GitHub Downloads - All Releases Release GitHub Release Date - Published_At

GitHub Sponsor Ko-Fi Button

Block Entire Folder in Windows Firewall

This script provides functionalities to manage (block/unblock) executables (EXEs) in specified directories via Windows Firewall. The operation can be targeted at individual directories or recursively applied to subdirectories as well.

By default, both Inbound and Outbound connections will be affected, but the scope can be controlled via the -Inbound or -Outbound switches.

Special care should be taken when using this script due to its potentially broad impact. Blocking EXEs indiscriminately may disrupt applications depending on these executables.

Installing

You can either download the PS1 script from here, or install using...

Install-Script BlockFolderWindowsFirewall -Force

Answer Yes to any prompts. -Force is optional, but it will force the script to update if it is outdated.

This script is published on PowerShell Gallery.

Usage

BlockFolderWindowsFirewall [-Path <String>] [-Outbound] [-Inbound] [-Recurse] [-UnblockInstead] [-Version] [-Help] [-CheckForUpdate]

Parameters

Parameter Required Description
-Path Yes The folder of EXEs to block/unblock.
-Recurse No Scans the folder and subfolders for EXEs.
-UnblockInstead No Unblocks the EXEs in a folder or subfolder.
-Inbound No Blocks all inbound connections for the EXEs in a folder or subfolder.
-Outbound No Blocks all outbound connections for the EXEs in a folder or subfolder.
-CheckForUpdate No Checks if there is an update available for the script.
-UpdateSelf No Updates the script to the latest version.
-Help No Displays the help message.
-Version No Shows the current version of the script.

Examples

Description Command
Block all EXEs in a specified folder BlockFolderWindowsFirewall -Path "C:\Folder\Subfolder"
Block all EXEs in a specified folder and its subfolders BlockFolderWindowsFirewall -Path "C:\Folder\Subfolder" -Recurse
Block only the inbound connections for EXEs in a specified folder BlockFolderWindowsFirewall -Path "C:\Folder\Subfolder" -Inbound
Block only the outbound connections for EXEs in a specified folder BlockFolderWindowsFirewall -Path "C:\Folder\Subfolder" -Outbound
Unblock all EXEs in a specified folder BlockFolderWindowsFirewall -Path "C:\Folder\Subfolder" -UnblockInstead
Unblock all EXEs in a specified folder and its subfolders BlockFolderWindowsFirewall -Path "C:\Folder\Subfolder" -Recurse -UnblockInstead
Unblock only the inbound connections for EXEs in a specified folder BlockFolderWindowsFirewall -Path "C:\Folder\Subfolder" -UnblockInstead -Inbound
Unblock only the outbound connections for EXEs in a specified folder BlockFolderWindowsFirewall -Path "C:\Folder\Subfolder" -UnblockInstead -Outbound
Display help for the script BlockFolderWindowsFirewall -Help
Check the current version of the script BlockFolderWindowsFirewall -Version
Check if there is an update available for the script BlockFolderWindowsFirewall -CheckForUpdate

Screenshot

Screenshot