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.
Note: Firewall is a key line of defense for your network against unauthorized access and malicious programs. While you can temporarily disable it for testing or other purposes, we advise enabling it afterward.
How to Enable Firewall via Powershell
Press Windows + X to open the quick link menu.
1- Press A and accept the prompt to launch Windows PowerShell (Admin).
2- Use the following commands as required. Type them and press Enter after each.
3- Enable Firewall entirely:
Set-NetFirewallProfile -Enabled True
4- Enable Firewall for a specific profile(s):
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled True
5- Check the Network Profiles section for more on this.
6- Check if Firewall is enabled:
netsh advfirewall show all
How to Disable Firewall via Powershell
1- Press Windows + X to open the quick link menu.
2- Press A and accept the prompt to launch Windows PowerShell (Admin).
3- Use the following commands as required. Type them and press Enter after each.
4- Disable Firewall entirely:
Set-NetFirewallProfile -Enabled False
5- Disable Firewall for a specific profile(s):
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False
6- Check the Network Profiles section for more on this.
7- Check if Firewall is disabled:
netsh advfirewall show all
Remotely Enable/Disable Firewall with Powershell
Note: WinRM needs to be set up beforehand on the target computer for remote disabling to work. Check out How to enable Windows Remote Shell for more on that.
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
1- Press Windows + R to launch Run.
2- 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.
3- Enable Firewall entirely:
netsh advfirewall set allprofiles state off
4- Enable Firewall for the current profile:
netsh advfirewall set currentprofile state off
5- Enable Firewall for a specific profile(s).
netsh advfirewall set publicprofile state off
6- Replace public with domain or private as appropriate. Check the Network Profiles section for more on this.
7- 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:
1- Press Windows + R to launch Run.
2- Type windowsdefender://network/
and press Enter to open the Firewall and Network protection window.
3- 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:
1- Press Windows + R to launch Run.
2- Type windowsdefender://network/
and press Enter.
3- Click on Allow an App through Firewall.
4- Press Change Settings.
5- 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.
6- 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?
1- Press Windows + I to launch Settings.
2- Go to Network and Internet > Ethernet.
3- Press Change Advanced Sharing Settings on the right.
4- Adjust sharing settings as appropriate and click Save Changes.