Manage Windows Firewall with the Command Prompt / PowerShell


Software: Windows 7, 8 & 10 | Last modified on 2018-06-18


A guide to configuring and resetting the Windows Firewall with the Command Prompt or PowerShell.

Enable & disable the Windows Firewall


  1. Open the Command Prompt (Admin) or PowerShell (Admin).

  • Execute netsh advfirewall set allprofiles state on to enable the Window Firewall for all user accounts.
  • Execute netsh advfirewall set allprofiles state off to disable the Window Firewall for all user accounts.


Reset the Windows Firewall


  1. Open the Command Prompt (Admin) or PowerShell (Admin).

  • Execute netsh advfirewall reset to reset the policy to the default out-of-box policy.


Import & export the Windows Firewall policy


  1. Open the Command Prompt (Admin) or PowerShell (Admin).

  • Execute netsh advfirewall export "Path\FirewallBackup.wfw" to export the current policy to a file.
    Example: netsh advfirewall export "C:\Backup\FirewallBackup.wfw"
    Replace Path with the location where you want to save the file.

  • Execute netsh advfirewall import "Path\FirewallBackup.wfw" to import a policy file into the current policy store.
    Example: netsh advfirewall import "C:\Backup\FirewallBackup.wfw"
    Replace Path with the location where you've saved the file.


Show the Windows Firewall policy per profile


  1. Open the Command Prompt (Admin) or PowerShell (Admin).

  • Execute netsh advfirewall show global to display the global properties.
  • Execute netsh advfirewall show allprofiles to display the properties for all profiles.
  • Execute netsh advfirewall show currentprofile to displays the properties for the active profile.
  • Execute netsh advfirewall show domainprofile to displays the properties for the domain properties.
  • Execute netsh advfirewall show privateprofile to displays the properties for the private profile.
  • Execute netsh advfirewall show publicprofile to displays the properties for the public profile.



Search
Support
Can't find the answer you're looking for? Click here to submit a ticket.