How to Enable Windows Firewall using PowerShell

Windows Firewall is an essential security feature that protects your system from unauthorized access and threats. If it has been disabled for testing or mistakenly turned off, you can quickly re-enable it using PowerShell.

This guide provides a straightforward process to restore your firewall settings and ensure a secure environment. To enable Windows Firewall with PowerShell, follow these steps:
> Step 1: Understanding Windows Firewall Profiles
> Step 2: Check Current Firewall Status
> Step 3: Enable Windows Firewall

Step 1: Understanding Windows Firewall Profiles

Before running scripts or commands on a computer, it’s important for us to understand what each step is doing. We are enabling the Windows Firewall for all Profiles:
> Domain: For when you are connected to a Domain Controller (computer connected to AD).
> Private: For your home or private networks.
> Public : For public WIFI locations such as coffee shops etc.

Make sure you understand which profile applies to your scenario before proceeding. You can also manage these settings via the GUI for additional clarity:

Windows Firewall status

Step 2: Check Current Firewall Status

Before enabling the firewall, check its current status using the following PowerShell command:

# get local firewall status
Get-NetFirewallProfile | Format-Table Name, Enabled
Get-NetFirewallProfile example

This command retrieves the status of all firewall profiles and displays whether they are enabled (True) or disabled (False).

Step 3: Enable Windows Firewall

To enable the Windows Firewall for all profiles, use the Set-NetFirewallProfile cmdlet. Run the following command in PowerShell or Windows Terminal with admin privileges:

# disable local firewall
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled True

# get local firewall status
Get-NetFirewallProfile | Format-Table Name, Enabled
enable windows firewall with powershell example

By enabling the firewall, you significantly improve your system’s defense against unauthorized access and potential cyber threats. However, enabling the firewall may block some desired connectivity, requiring you to create new firewall rules to allow specific traffic while maintaining overall security. For detailed guidance on advanced configurations and creating firewall rules, refer to the official Microsoft documentation on the Windows Firewall.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *