Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

Using Set-NetFirewallSetting in PowerShell for Advanced Configuration of Windows Firewall

In this article, we will explore the powerful capabilities of the Set-NetFirewallSetting cmdlet in PowerShell for configuring the Windows Firewall in a more advanced and granular manner. The Windows Firewall is a crucial component of the Windows operating system, providing protection against unauthorized access and malicious activities. By understanding and utilizing the Set-NetFirewallSetting cmdlet, users can enhance their security posture and tailor the firewall settings to meet their specific requirements.


Examples:


1. Enabling or Disabling the Windows Firewall:
To enable the Windows Firewall, open a PowerShell session with administrative privileges and run the following command:


Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled True

To disable the Windows Firewall, use the following command:


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

2. Configuring Inbound and Outbound Rules:
To create a new inbound rule, execute the following command:


New-NetFirewallRule -DisplayName "Allow HTTP" -Direction Inbound -Protocol TCP -LocalPort 80 -Action Allow

To create a new outbound rule, use the following command:


New-NetFirewallRule -DisplayName "Allow DNS" -Direction Outbound -Protocol UDP -LocalPort 53 -Action Allow

3. Modifying Existing Rules:
To change the action of an existing rule, use the Set-NetFirewallRule cmdlet. For example, to change the action of the "Allow HTTP" rule to Block, run the following command:


Set-NetFirewallRule -DisplayName "Allow HTTP" -Action Block

To share Download PDF