Powershell - list Firewall rules

WW-6729 371 Reputation points
2021-04-26T13:26:39+00:00

Hi!

I use this powershell commands for listing firewall rules:

Get-NetFirewallRule -Direction Inbound | Select-Object Name, DisplayName, Description

Show-NetFirewallRule | where {$_.enabled -eq true' -AND $_.direction -eq inbound'}| select displayname

With these commands I can't see rules applied through GPO. Does anybody know how can I accomplish this?

Thank you!

Best regards.

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,354 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. WW-6729 371 Reputation points
    2021-04-26T13:51:01.413+00:00

    Update!

    I've managed to get it using this command:

    Get-NetFirewallRule -PolicyStore ActiveStore | Where-Object {$_.Description -eq "My_GPO"}

    As per MS we must user -PolicyStore for GPO applied policies.

    Now, my question is what gives this rule a Name because I can see it is some kind of guid and can I locate this guid Name on a computer (the name my GPO has is under DisplayName:
    91256-image.png

    0 comments No comments

  2. Ian Xue (Shanghai Wicresoft Co., Ltd.) 29,486 Reputation points Microsoft Vendor
    2021-04-27T06:17:12.303+00:00

    Hi,

    The name is a random GUID generated by the NewGuid() method.
    https://learn.microsoft.com/en-us/dotnet/api/system.guid.newguid

    You can use the GUID to locate the firewall rule with the Where-Object cmdlet.

    Best Regards,
    Ian Xue

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

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments