Home > PowerShell Scripting, Windows Server > Disable the Windows Firewall in Server 8 Beta, with Powershell

Disable the Windows Firewall in Server 8 Beta, with Powershell

(Note: this will also work with Windows 8 Consumer Preview)

While troubleshooting an issue in windows server 8’s new Powershell Web Access, I had the need to disable the windows firewall. Normally I would use a “netsh firewall” command, but when running this in windows server 8 we receive the notification:

“In future versions of Windows, Microsoft might remove the Netsh Functionality for windows firewall with Advanced Security”

“If you currently use Netsh firewall to configure and manage Windows Firewall with advanced Security, Microsoft recommends that you transition to Windows Powershell.”

This message continues in the screenshot below:

So with the warning in mind, I decided it was time to learn the new thing for the day and off I went to find out how to quickly disable the firewall using powershell!

As above the first clue is in the message, a new module seems to be available on both Windows 8 and Server 8. So with a quick get-module -listavailable I can see netsecurity listed:

“So what commands can I use with the netsecurity module” I asked myself. I ran a quick “Get-Command -module NetSecurity” and was overwhelmed with a large list of potential candidates as below:

So I used the trusted “Import-Module NetSecurity” command and set about reading the help files. Or so I thought…

As with PowerShell 3.0, the helpfiles for Powershell are not completely installed by default, we need to run update-help to download the powershell help files. This is causing quite a debate in the powershell community, so I’m not going to get into this, personally I think its a good idea.

Anyway, so off I went to update the help, or so I thought:


I’ll admit, this list had me scratching my head for some time, but I soon enough stumbled across the important command on this list for my objective. “Get-NetFirewallProfile”.

Get-NetFirewallProfile lists out the firewall profiles for your machine. The profiles are separated out into Domain, Public and Private as you can see in the screen-shot below:

Now that we’re aware of where the profiles live, its just a simple task of piping the current profiles, into a “Set-NetFirewallProfile” command to turn the profiles off.

Below is a quick on-liner to disable the windows firewall in Server 8 or Windows 8 completely:

Import-Module NetSecurity -ea Stop ; Get-NetFirewallProfile | Set-NetfirewallProfile -Enabled False

And that’s it!

And once finished troubleshooting, you can turn it back on as below:

Import-Module NetSecurity -ea Stop ; Get-NetFirewallProfile | Set-NetfirewallProfile -Enabled True
  1. Remo
    September 6, 2012 at 3:08 pm

    I needed this for HyperV server 2012 final version.

  2. November 22, 2012 at 2:23 pm

    Me too! Couldn’t seem to be able to connect via the Hyper-V Manager 😦

  3. February 8, 2013 at 9:25 am

    Shouldn’t the command to enable firewall be “Import-Module NetSecurity -ea Start”, instead?

  4. @gonsalu
    February 8, 2013 at 10:34 am

    Nevermind; “Start” is not even a valid -ErrorAction. Too much PowerShell for a single day 🙂

  5. Anon
    March 8, 2013 at 2:07 pm

    Rather than iterating over each profile you can set the lot using
    Set-NetworkProfile -All -Enabled False
    (as found on http://letitknow.wordpress.com/2012/09/13/manage-windows-firewall-with-powershell-3/ )

  6. April 12, 2013 at 1:28 pm

    Thanks a lot… I was just hitting my head on table to stop Windows 2012 Server Core Firewall.

    To cut short, what I used is

    To Disable public profile of Windows 2012 Firewall

    “Set-NetfirewallProfile -Name public -Enabled false”

    To Disable private profile of Windows 2012 Firewall

    “Set-NetfirewallProfile -Name private -Enabled false”

    Thanks a lot for the wonderful tech blog.

    Chennai MCSE

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

<span>%d</span> bloggers like this: