Automate firewall policy rule update in GPO

P Mowleeswaran 25 Reputation points
2024-10-10T08:42:20.5566667+00:00

Hello Team,

We are applying firewall rules for all my domain machines through GPO. I have three GPOs for firewall rules that apply to workstations, servers, and domain controllers. Therefore, we have different sets of inbound and outbound firewall rules for each GPO.

Now, I need a PowerShell script that updates the remote address for a particular rule in a specific GPO . I would like to provide input in a data preparation file, and the script should apply the remote address for that particular GPO.

For example, I have the GPOs Wks_Firewall_GPO, Server_Firewall_GPO, and DC_Firewall_GPO on my domain controller. In the Wks_Firewall_GPO, I have an inbound rule for which I need to add a few more remote addresses via the PowerShell script. i need to execute this script from my domain controller.

Could you please assist me with this?

Regards,

Mowlee

Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2024-10-11T07:30:26.9366667+00:00

    Hello P Mowleeswaran,

    Thank you for posting in Q&A forum.

    I am sorry we don’t directly write script for use on the forum, and I am not familiar with script.

    I think you could use the Get-GPO, Get-GPRegistryValue, and Set-GPRegistryValue cmdlets to achieve it.

    For example:

    Get-GPO -Name "YourGPOName"

    Get-GPRegistryValue -Name "YourGPOName" -Key “registryPath”  -ValueName ”ruleName”

    References:

    Get-GPO (GroupPolicy) | Microsoft Learn

    Get-GPRegistryValue (GroupPolicy) | Microsoft Learn

    Set-GPRegistryValue (GroupPolicy) | Microsoft Learn

    I hope the information above is helpful.

    If you have any questions or concerns, please feel free to let us know.

    Best Regards,

    Daisy Zhou

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.