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 10 Network
Windows 10 Network
Windows 10: A Microsoft operating system that runs on personal computers and tablets.Network: A group of devices that communicate either wirelessly or via a physical connection.
2,311 questions
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,449 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ian Xue (Shanghai Wicresoft Co., Ltd.) 33,951 Reputation points Microsoft Vendor
    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.