We can use the Get-NetFirewallRule cmdlet to achieve this. First, let us see how we can use this cmdlet on the local system.
The above command will list all available Firewall rules irrespective of their state (enabled or disabled) or action (allowed or denied). To filter this further to only enabled firewall rules, we can run:
We can filter this further and retrieve only the rules that are enabled and are set to allow.
So, how do we use this to retrieve the rules from a remote system? Simple, we need to use a computer name string or a CIM session object as an argument to the -CimSession parameter of Get-NetFirewallRule cmdlet.