Net-NewFirewallFule from NetSecurity module fails to add rule to Local GPO store policy

Nkei 11 Reputation points
2022-05-10T17:10:43.203+00:00

By default, Windows has at least 2 Firewall rules sources: weird local and local group policy. In netsh you can easily switch between them:

netsh advfirewall set store gpo=COMUTERNAME
netsh advfirewall set store local

Any requests to commands *-NewFirewallFule will operate on Local source. I found information that in order to add to Local Group Policy Source you need to specify localhost as a store:

New-NetFirewallRule -Name Blah -PolicyStore localhost

The issue is that while I can easily add any rule via netsh to Local GPO (or do it via MMC's module Local Security Settings), an attempt to use -PolicyStore localhost results in:

Get-NetFirewallRule: The network path was not found.

What could be the issue? This is purely home user client machine, no AD used.

Windows for business | Windows Client for IT Pros | Networking | Network connectivity and file sharing
Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2022-05-25T05:22:21.89+00:00

    Hi,

    According to the help file of the Get-NetFirewallRule, the local GPOs can be specified with the hostname. Please see if the command works with the hostname.

    Get-NetFirewallRule -PolicyStore $hostname -Name $name

    https://learn.microsoft.com/en-us/powershell/module/netsecurity/get-netfirewallrule

    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.


Your answer

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