Turn Windows Firewall Off or On By Command Line Or Script

in technology •  6 years ago 

I have run into a few times when I needed to turn off or on the Windows Firewall via command line or script. It is actually very simple to do!

To Turn Off:
NetSh Advfirewall set allprofiles state off

To Turn On:
NetSh Advfirewall set allrprofiles state on

To check the status of Windows Firewall:
Netsh Advfirewall show allprofiles

You can replace "allprofiles" with public, domain, or private and you can manipulate just that one profile. I used this in creating a script to test the firewall settings of a remote server. That way if I messed up the config, it would turn itself back off after a minute and I was able to reconnect to it. You can view that script on my other post Testing Windows Firewall Settings Safely From Remote Machine.


Originally posted at https://moreabout.tech/turn-windows-firewall-off-or-on-by-command-line-or-script/

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!