Tech News Today
  • Hardware
    • Motherboards
    • CPUs
    • Graphic Cards
    • RAM
    • SSDs
    • Computer Cases
    • Monitors
    • Peripherals
    • Power Supply Unit
    • PC Builds
    • Computer Tips
  • Software
  • Operating System
    • Windows
    • Mac
    • Linux
  • Gaming
  • Mobile
  • Console
  • More
    • Internet
    • Networking
    • Security
    • Buyer’s Guide
    • Gadgets
    • Laptops
    • Reviews
    • How To
    • News
Facebook Twitter Instagram
Tech News Today
  • Hardware
    • Motherboards
    • CPUs
    • Graphic Cards
    • RAM
    • SSDs
    • Computer Cases
    • Monitors
    • Peripherals
    • Power Supply Unit
    • PC Builds
    • Computer Tips
  • Software
  • Operating System
    • Windows
    • Mac
    • Linux
  • Gaming
  • Mobile
  • Console
  • More
    • Internet
    • Networking
    • Security
    • Buyer’s Guide
    • Gadgets
    • Laptops
    • Reviews
    • How To
    • News
Tech News Today
Home»How To»How To Enable Or Disable Firewall Using Powershell

How To Enable Or Disable Firewall Using Powershell

Anup ThapaBy Anup ThapaMarch 21, 2022
powershell disable firewall

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.

Table of Contents

  • How to Enable Firewall via Powershell
  • How to Disable Firewall via Powershell
  • Remotely Enable/Disable Firewall with Powershell
    • Disable Firewall on One Remote Computer
  • Disable Firewall On Multiple Remote Computers
  • How to Enable/Disable Firewall Using Command Prompt?
    • Enable Firewall via CMD
    • Disable Firewall via CMD
  • Network Profiles
  • Related Questions
    • How to Enable/Disable Firewall Through GUI?
    • How to Allow an App through Windows Firewall?
    • GUI vs. CLI. Which Is Better For Disabling Firewall?
    • Is It Safe To Disable Windows Firewall?
    • How to Change Sharing Settings for Network Profiles?

How to Enable 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. Enable Firewall entirely:
    Set-NetFirewallProfile -Enabled True
  5. Enable Firewall for a specific profile(s):
    Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled True
    Check the Network Profiles section for more on this.
  6. Check if Firewall is enabled:
    netsh advfirewall show all
    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
    Check the Network Profiles section for more on this.
    Powershell-disable-firewall-domain-public-private
  6. 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

Powershell-remote-disable-firewall

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
}
}

Remote-disable-firewall-multple-computers

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

  1. Press Windows + R to launch Run.
  2. Type cmd and press CTRL + Shift + Enter to launch elevated Command Prompt.
  3. Use the following commands as required. Type them and press Enter after each.
  4. Enable Firewall entirely:
    netsh advfirewall set allprofiles state on
    cmd-netsh-advfirewall-set-allprofiles-state-on
  5. Enable Firewall for the current profile:
    netsh advfirewall set currentprofile state on
  6. 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.
  7. 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.
  3. Use the following commands as required. Type them and press Enter after each.
  4. Enable Firewall entirely:
    netsh advfirewall set allprofiles state off
  5. Enable Firewall for the current profile:
    netsh advfirewall set currentprofile state off
  6. 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.
  7. Check if Firewall is disabled:
    netsh advfirewall show all
    cmd-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.
    disable-firewall-gui-windows-security

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.
    Windows-Defender-Firewall-Allowed-Apps
  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.
    Network-Advanced-Sharing-Settings
how-to
Anup Thapa
  • LinkedIn

Anup Thapa is a tech writer at TechNewsToday. He mostly writes informative articles, tutorials, and troubleshooting guides related to Windows systems, networking, and computer hardware. Anup has been writing professionally for almost 5 years, and tinkering with PCs for much longer. His love for all things tech started when he got his first PC over 15 years ago. It was a Pentium IV system running Windows XP on a single 256 MB stick. He spent his formative years glued to this PC, troubleshooting any hardware or software problems he encountered by himself. Professionally, Anup has had brief forays into a variety of fields like coding, hardware installation, writing, etc. In doing so, he's worked with people of different backgrounds and skill levels, from average joes to industry leaders and experts. This has given him not just a versatile skillset, but also a unique perspective for writing that enables him to concisely communicate complex information and solve his reader's problems efficiently. You can contact him at anup@technewstoday.com

Related Posts

wifi-keeps-disconnecting-windows-11

Wi-Fi Keeps Disconnecting on Windows 11? 9 Ways to Fix It

February 26, 2023
windows-cannot-access-network-drive

Fix: Windows Cannot Access Network Drive

February 23, 2023
how to check wifi speed in laptop

3 Simple Ways to Check Wi-Fi Speed in Laptop

February 23, 2023
network_adapter_not_working

Network Adapter Not Working? 15 Ways to Fix It

February 22, 2023
Surface WiFi Not Working

Why is My Wi-Fi Not Working on Surface Laptop? 10 Ways to Fix It

February 22, 2023
change-network-profile-windows

4 Ways to Change Network Profile in Windows

February 22, 2023
Add A Comment

Leave A Reply Cancel Reply

Latest Posts
Memory-Compression

What is Memory Compression in Windows? Should You Enable or Disable It

March 1, 2023
dism-vs-sfc-vs-chdsk

DISM, SFC, CHKDSK: What’s the Difference

February 28, 2023
bios-settings-for-gaming

Best BIOS Settings for Gaming

February 16, 2023
You may also like
how-to-clean-hp-printer-rollers

How to Clean HP Printer Rollers

March 3, 2023
keyboard input lag

9 Ways to Fix Keyboard Input Lag

March 3, 2023
keyboard key is stuck

How to Fix a Stuck Key on a Keyboard

March 3, 2023
Recommended
Cookie Clicker Garden Guide

Cookie Clicker Garden Guide to Unlocking Every Seed

September 26, 2021
monitor no signal

Computer Turns On But Monitor Says No Signal (9 Ways To Fix)

November 10, 2022
Facebook Twitter Pinterest
  • Home
  • About Us
  • Our Team
  • Editorial Guidelines
  • Privacy Policy
  • Affiliate Disclosure
© 2023 TechNewsToday, editor@technewstoday.com | Tech Central Pvt. Ltd.

Type above and press Enter to search. Press Esc to cancel.