Skip to content

About

PowerShell Module to manage the Windows Firewall

Resources

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

WindowsFirewall

PowerShell Module to manage the Windows Firewall

Available Commands

Command Synopsis
Get-WindowsFirewallDynamicKeywordAddress Gets Windows firewall dynamic keyword addresses
Get-WindowsFirewallEventLogTraffic Gets audited traffic and the firewall filter that allowed or blocked it
Get-WindowsFirewallRule Gets all properties of a Windows firewall rule
Get-WindowsFirewallRuleExpiration Gets expiration of a temporary firewall rule
Get-WindowsFirewallRuleSDDLString Generates SDDL string for use with secure firewall rule
New-WindowsFirewallDynamicKeywordAddress Creates a dynamic keyword address
New-WindowsFirewallRule Creates a new Windows firewall rule
New-WindowsFirewallTempRule Creates a new Windows firewall temporary allow or block rule
Remove-WindowsFirewallDynamicKeywordAddress Removes a dynamic keyword address
Set-WindowsFirewallProfile Configures a Windows firewall profile
Set-WindowsFirewallRule Applies a specified Windows firewall JSON ruleset
Start-WindowsFirewallAuditLogging Enables Filtering Platform audit logging
Stop-WindowsFirewallAuditLogging Restores the audit policy from before audit logging was started
Test-WindowsFirewallHealthProbe Tests Windows firewall health and attempts remediation

Usage

To apply a set of JSON-defined Windows firewall rules

> Set-WindowsFirewallRule -RuleFile FirewallRules.json

To apply rules that reference dynamic keyword addresses by name (see Rules\DynamicRules.json and DynamicKeywordAddresses\DynamicKeywordAddresses.json)

> Set-WindowsFirewallRule -RuleFile DynamicRules.json -DynamicKeywordAddressFile DynamicKeywordAddresses.json

A rule that names a dynamic keyword address not defined in these files stops the run before any rule is applied To apply rules without disabling any other rules

> Set-WindowsFirewallRule -RuleFile FirewallRules.json -Additive

To configure the Windows firewall profile

> Set-WindowsFirewallProfile -NetworkProfile Domain -DefaultInboundAction Block -DefaultOutboundAction Allow

To find which firewall filter is blocking traffic

> Start-WindowsFirewallAuditLogging
> # Reproduce the traffic
> Get-WindowsFirewallEventLogTraffic -Action Blocked -Port 443
> Stop-WindowsFirewallAuditLogging

Rule applications

Instead of a fixed Program path, a rule can set Application to find the program when the rules are applied. If the application isn't found, WhenMissing decides whether the rule is skipped (Skip) or fails (Fail, the default)

  • ExeSearch: the newest ExecutableName found under RootDirs (default: both Program Files directories), searching Depth levels deep (default 5). DirectoryNamePattern optionally filters on the name of the folder the executable is in
  • AppxPackage with Target Program: ExecutableRelativePath inside the newest installed PackageName package
  • AppxPackage with Target Package: the PackageFamilyName package

About

PowerShell Module to manage the Windows Firewall

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages