I'm writing a large script that goes through and applies a load of local policy settings via Powershell. Most of this is done by exporting the current security config via Secedit, passing this to an arraylist, adding/updating values as needed, then exporting the arraylist and importing back using Secedit.
My issue is that I need to set the local Firewall policy (Computer Configuration\Policies\Windows Settings\Security Settings\Windows Firewall with Advanced Security\Windows Firewall with Advanced Security\Windows Firewall Properties\Domain Profile\Firewall state) and this has caused me to get stuck.
I am able to manipulate the Local Firewall settings using
$Domain = Get-NetFirewallProfile -name domain $domain | Set-NetFirewallProfile -DefaultInboundAction allow
But this is not manipulating the Policy.
I am also able to manipulate the registry keys that get written/updated when the policy is changed, however changing these does not show the Policy as changing for example:
Does not show the policy as changed, if a gpupdate /force is run - this setting gets wiped (from memory this is because the Policy is contained in the security DB under c:\windows\security)
I've tried adding in the Reg Key to the file that is imported via secedit - which successfully loads but does not manipulate the setting.
I've tried using open-netgpo - but I am unable as this is not a Domain joined machine (and will never be Domain joined) and I cannot pass a valid option for policystore in order to get it to manipulate the local Firewall policy
I would ideally like to have this controlled via the Local Policy as opposed to just the active Firewall setting.
I am hoping that there is a way to change the Firewall policy using Powershell so I can complete what I need to in an automated manner.