Created
October 20, 2025 00:02
-
-
Save LinkPhoenix/57db5a93d5845bf64a31d02cd2aebca3 to your computer and use it in GitHub Desktop.
Interactive PowerShell tool to manage or disable Windows Defender Firewall when using Fort Firewall to prevent duplicate notifications.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <# | |
| .SYNOPSIS | |
| Configure Windows Defender Firewall interactively to ensure compatibility with Fort Firewall. | |
| .DESCRIPTION | |
| This script provides an interactive interface to view and manage Windows Defender Firewall settings. | |
| It includes options to enable, disable, or reset firewall profiles via PowerShell or netsh commands. | |
| Created to disable Windows Firewall when Fort Firewall is used, preventing notifications. | |
| .PARAMETER None | |
| No parameters required. The script runs interactively with user input. | |
| .EXAMPLE | |
| .\Configure-WindowsFirewall.ps1 | |
| Launches an interactive menu to configure or disable Windows Defender Firewall. | |
| .NOTES | |
| Created: 2025-10-20 | |
| Version: 1.0 | |
| #> | |
| function Get-FirewallState { | |
| try { | |
| $profiles = Get-NetFirewallProfile -Profile Domain,Public,Private | |
| return @{ | |
| Domain = ($profiles | Where-Object Profile -EQ 'Domain').Enabled | |
| Public = ($profiles | Where-Object Profile -EQ 'Public').Enabled | |
| Private = ($profiles | Where-Object Profile -EQ 'Private').Enabled | |
| } | |
| } catch { | |
| return $null | |
| } | |
| } | |
| function Show-Menu { | |
| Clear-Host | |
| Write-Host "=== Windows Defender Firewall Configuration Manager ===" -ForegroundColor Cyan | |
| $state = Get-FirewallState | |
| if ($state) { | |
| Write-Host "`nCurrent firewall states:" | |
| Write-Host " Domain : $($state.Domain)" | |
| Write-Host " Public : $($state.Public)" | |
| Write-Host " Private: $($state.Private)`n" | |
| } else { | |
| Write-Host "`nUnable to retrieve firewall state.`n" | |
| } | |
| Write-Host "Select an action:" | |
| Write-Host "[1] Enable via PowerShell cmdlet" | |
| Write-Host "[2] Disable via PowerShell cmdlet" | |
| Write-Host "[3] Enable via netsh" | |
| Write-Host "[4] Disable via netsh" | |
| Write-Host "[5] Reset configuration via netsh" | |
| Write-Host "[Q] Quit`n" | |
| } | |
| function Apply-Action { | |
| param ($choice) | |
| switch ($choice) { | |
| '1' { | |
| Write-Host "`nEnabling firewall via PowerShell..." -ForegroundColor Green | |
| Set-NetFirewallProfile –Profile Domain,Public,Private –Enabled True | |
| } | |
| '2' { | |
| Write-Host "`nDisabling firewall via PowerShell..." -ForegroundColor Yellow | |
| Set-NetFirewallProfile –Profile Domain,Public,Private –Enabled False | |
| } | |
| '3' { | |
| Write-Host "`nEnabling firewall via netsh..." -ForegroundColor Green | |
| netsh advfirewall set allprofiles state on | |
| } | |
| '4' { | |
| Write-Host "`nDisabling firewall via netsh..." -ForegroundColor Yellow | |
| netsh advfirewall set allprofiles state off | |
| } | |
| '5' { | |
| Write-Host "`nResetting firewall configuration via netsh..." -ForegroundColor Magenta | |
| netsh advfirewall reset | |
| } | |
| default { | |
| Write-Host "`nInvalid selection." -ForegroundColor Red | |
| return | |
| } | |
| } | |
| Write-Host "Forcing Group Policy update..." -ForegroundColor Cyan | |
| gpupdate /force | Out-Null | |
| Write-Host "Operation complete.`n" -ForegroundColor Green | |
| Start-Sleep -Seconds 2 | |
| } | |
| #endregion | |
| # Main interactive loop | |
| do { | |
| Show-Menu | |
| $choice = Read-Host "Enter choice" | |
| if ($choice.ToUpper() -eq 'Q') { | |
| Write-Host "`nExiting." -ForegroundColor Cyan | |
| break | |
| } | |
| Apply-Action -choice $choice | |
| } while ($true) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment