Category filter
Execute scripts to turn on Firewall on Windows devices
Windows Firewall is a security mechanism that protects the device from unauthorized access. It helps secure the endpoints and permits you to create network rules for regulating network traffic. This doc assists you on how to configure firewall settings and rules using scripts via Hexnode UEM.
Setting up Windows Firewall using scripts
You can use both the Batch files and PowerShell commands to enable the firewall on Windows devices from the Hexnode console.
1. Batch Script
- To enable Firewall on all profiles specifically domain, private and public:
1netsh advfirewall set allprofiles state on
- To add a Firewall rule name for any given application (for instance, Internet Explorer) meant for the inbound traffic to the device:
1netsh advfirewall firewall add rule name=”SetUpFirewall” dir=in Program=”C:\Program Files\Internet Explorer” action=block
- To open a port in Firewall:
1netsh advfirewall firewall add rule name=”Allow Port 25” dir=in action=allow protocol=TCP localport=25
2. PowerShell Script
- To enable Firewall on all profiles specifically domain, private and public:
1Set-NetFirewallProfile -All -Enabled True
- To add Firewall rule name for any given application (for instance, Internet Explorer) meant for the inbound traffic to the device:
1New-NetFirewallRule –Name SetUpFirewall -DisplayName Enabling_firewall –Direction Inbound –Program C:\Program_Files\Internet_Explorer –Enabled True –Profile Any –Action Allow
- To open a port in Firewall:
1New-NetFirewallRule –DisplayName ‘Allow Port 25’ -Direction Inbound –Action Allow –Protocol TCP –LocalPort 25