How to disable windows firewall profiles using PowerShell?

There are 3 types of profiles that firewall supports. a) Domain b) Public and c) Private profile. You can check the same settings using the GUI in the Windows Firewall Advanced Security settings window as shown below.

You can check the above settings using the Get-NetFirewallProfile command.

Get-NetFirewallProfile | Select Name, Enabled 
Name    Enabled 
----   ------- 
Domain  True 
Private True
Public  True

To turn off or disable the above profiles using PowerShell, you need to use the command Set-NetFirewallProfile.

To disable the specific profile, use -Profile parameter. You can pass 3 different profile names in this parameter (Domain, Public, and Private). For example,

Set-NetFirewallProfile -Profile Domain -Enabled False

To disable all the windows firewall profiles,

Set-NetFirewallProfile -Profile Domain,Private,Public -Enabled False -Verbose

You can check the same with GUI or the first command mentioned in this article.

Get-NetFirewallProfile | Select Name, Enabled Name Enabled ---- ------- Domain False Private False Public False

To disable the settings on the remote computer, you need to use Invoke-Command or PSSession.

Invoke-Command -ComputerName RemoteServerName -ScriptBlock{ Set-NetFirewallProfile -Profile Domain, Private, Public -Enabled False}

Updated on: 28-Sep-2020


Kickstart Your Career

Get certified by completing the course

Get Started