In Powershell, you can easily enable or disable Windows Firewall using the Set-NetFirewallProfile
command. This cmdlet is used to configure the Firewall’s advanced security settings for a particular, or all, network profile.
While you can also disable Firewall using GUI options like Control Panel/Windows Settings, doing it via CLI options like PowerShell/CMD is more efficient.
How to Enable Firewall via Powershell
- Press Windows + X to open the quick link menu.
- Press A and accept the prompt to launch Windows PowerShell (Admin).
- Use the following commands as required. Type them and press Enter after each.
- Enable Firewall entirely:
Set-NetFirewallProfile -Enabled True
- Enable Firewall for a specific profile(s):
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled True
Check the Network Profiles section for more on this. - Check if Firewall is enabled:
netsh advfirewall show all
How to Disable Firewall via Powershell
- Press Windows + X to open the quick link menu.
- Press A and accept the prompt to launch Windows PowerShell (Admin).
- Use the following commands as required. Type them and press Enter after each.
- Disable Firewall entirely:
Set-NetFirewallProfile -Enabled False
- Disable Firewall for a specific profile(s):
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False
Check the Network Profiles section for more on this. - Check if Firewall is disabled:
netsh advfirewall show all
Remotely Enable/Disable Firewall with Powershell
Disable Firewall on One Remote Computer
Replace acer22 with the remote computer’s name and use the following commands:
Enter-PsSession -ComputerName acer22
Set-NetFirewallProfile -All -Enabled False
Disable Firewall On Multiple Remote Computers
Replace acer22 nitro15 dell and so on with the remote computers’ names and add or subtract more names as appropriate. Then use the following commands:
$computers = @(‘acer22', ‘nitro15’, ‘dell’)
$computers | ForEach-Object {
Invoke-Command-ComputerName $_ {
Set-NetFirewallProfile-All -Enabled False
}
}
How to Enable/Disable Firewall Using Command Prompt?
In CMD, we’ll use the netsh advfirewall
command to enable/disable the firewall. This command also allows for precise control of firewall rules for each of the profiles (Domain, Public, Private).
Enable Firewall via CMD
- Press Windows + R to launch Run.
- Type cmd and press CTRL + Shift + Enter to launch elevated Command Prompt.
- Use the following commands as required. Type them and press Enter after each.
- Enable Firewall entirely:
netsh advfirewall set allprofiles state on
- Enable Firewall for the current profile:
netsh advfirewall set currentprofile state on
- Enable Firewall for a specific profile(s):
netsh advfirewall set publicprofile state on
Replace public with domain or private as appropriate. Check the Network Profiles section for more on this. - Check if Firewall is enabled:
netsh advfirewall show all
Disable Firewall via CMD
- Press Windows + R to launch Run.
- Type cmd and press CTRL + Shift + Enter to launch elevated Command Prompt.
- Use the following commands as required. Type them and press Enter after each.
- Enable Firewall entirely:
netsh advfirewall set allprofiles state off
- Enable Firewall for the current profile:
netsh advfirewall set currentprofile state off
- Enable Firewall for a specific profile(s).
netsh advfirewall set publicprofile state off
Replace public with domain or private as appropriate. Check the Network Profiles section for more on this. - Check if Firewall is disabled:
netsh advfirewall show all
Network Profiles
You can enable/disable the firewall for Domain, Public, Private profiles, or any combination of the three. Simply use the appropriate profiles in the commands above.
- Domain Profile: This applies to networks where the host system can authenticate to a domain controller. It’s applicable for business environments because of the high level of security and authentication.
- Private Profile: It is a user-assigned profile designed for trusted networks such as home or work networks. It’s generally safe to turn on Network Discovery and File sharing.
- Public Profile: It is the default profile, designed for public networks such as public Wi-Fi hotspots. We recommend turning off network discovery and file sharing for security reasons.
Related Questions
How to Enable/Disable Firewall Through GUI?
Enabling/Disabling the firewall via GUI is very simple. To do so:
- Press Windows + R to launch Run.
- Type
windowsdefender://network/
and press Enter to open the Firewall and Network protection window. - Click on your active profile and press the switch to turn the firewall on/off.
How to Allow an App through Windows Firewall?
A firewall monitors your network traffic and blocks harmful/inappropriate content. Occasionally, it can block or interfere with a trusted app that you need. In such cases, you can allow an app through the firewall with the following steps:
- Press Windows + R to launch Run.
- Type
windowsdefender://network/
and press Enter. - Click on Allow an App through Firewall.
- Press Change Settings.
- Check the tick box to allow the app through the app. Use Allow Another App if you don’t see your app on the list.
- Press OK to save the changes.
GUI vs. CLI. Which Is Better For Disabling Firewall?
You can use both GUI (Control Panel, Windows Settings) and CLI (Powershell, Command Prompt) to disable Firewall. It’s just a matter of preference.
Most users prefer GUI (Graphical User Interface) as it’s easier to understand and navigate. But CLI (Command Line Interface) is more efficient as you only need to enter a line of code to accomplish the same thing.
Is It Safe To Disable Windows Firewall?
A firewall is an important layer of security for your network. Ideally, you should use an antivirus along with Windows Firewall for proper protection.
It’s fine to disable the firewall temporarily. But we do not recommend keeping your firewall disabled in the long term. This would leave your network vulnerable to unauthorized access, malicious programs, and other cyber threats.
How to Change Sharing Settings for Network Profiles?
- Press Windows + I to launch Settings.
- Go to Network and Internet > Ethernet.
- Press Change Advanced Sharing Settings on the right.
- Adjust sharing settings as appropriate and click Save Changes.