Need Help Disabling Windows Firewall Profiles via PowerShell for Ansible Automation

Ambika Singh 0 Reputation points
2024-06-14T23:56:32.2766667+00:00

We have a requirement to set Windows Firewall profiles to "off" using Ansible Automation. Despite various attempts, the profiles reset/enabling upon reboot due to Group Policies. I am not able to disable the windows firewall profiles through Powershell or Registry Keys as on rebooting GroupPolicies are taking over and resetting/enabling the Domain, Public and Private Profiles. This is a required step to work with Ansible automation.

Tried the following methods:

PowerShell:

  • Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False
    • %ProgramFiles%\Windows Defender\MpCmdRun.exe -wdenable
    Registry Keys:
    - `Set-GPRegistryValue -Name "Firewall Domain Profile" -Key "HKLM:\SOFTWARE\Policies\Microsoft\WindowsFirewall\DomainProfile" -ValueName "EnableFirewall" -Type DWORD -Value 0`
    
       - `Set-GPRegistryValue -Name "Firewall Private Profile" -Key "HKLM:\SOFTWARE\Policies\Microsoft\WindowsFirewall\PrivateProfile" -ValueName "EnableFirewall" -Type DWORD -Value 0`
    
          - `Set-GPRegistryValue -Name "Firewall Public Profile" -Key "HKLM:\SOFTWARE\Policies\Microsoft\WindowsFirewall\PublicProfile" -ValueName "EnableFirewall" -Type DWORD -Value 0`
    
  1. Ansible Module:
    • win_firewall:
    • state: disabled
    • profiles:
            - `Domain`
      
                        - `Private`
      
                                    - `Public`
      
    Any advice on ensuring these settings persist across reboots would be greatly appreciated.error-1 BEFORE-CHANGE-FIREWALL AFTER-CHANGE-FIREWALL
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,222 questions
{count} votes