The easiest way to add port exceptions or computers not in Active Directory
How to Turn Windows Firewall On and Off Using Command Prompt
There may come a time when you need to write a script or connect to a PC remotely and run a command to turn Windows Firewall on or off. For most IT environments, the easiest way to configure Windows Firewall on client computers is through Group Policy.
It is also the easiest way to add port exceptions for services like HTTP, file sharing, software applications, and more. However, it is also good to know how to configure Windows Firewall from the command prompt, in case you have computers and servers that are not in Active Directory.
To first check if the Windows Firewall is enabled on a server or computer, type this command at the command prompt: