Unable to add firewall rule to local GPO using new-getfirewallrule

I'm trying to add firewall rule using New-NetFirewallRule cmdlet. By default the rule is added to local FW. As per this https://docs.microsoft.com/en-us/powershell/module/netsecurity/new-netfirewallrule?view=win10-ps to add the rule to local GPO, PolicyStore parameter needs to be set with either hostname or localhost parameter.

However when I try the command : New-NetFirewallRule -DisplayName “testing” -PolicyStore localhost , I get this error :

“New-NetFirewallRule : The network name cannot not found. At line:1 char:1 New-NetFirewallRule -DisplayName “testing” -PolicyStore localhost CategoryInfo : NotSpecified: (MSFT_NetFirewallRule:root/standardcimv2/MSFT_NetFirewallRule) [New-NetFir ewallRule], CimException FullyQualifiedErrorId : Windows System Error 67,New-NetFirewallRule”

 

Edit: Some times I get this error as well:

New-NetFirewallRule : Mutual Authentication failed. The server’s password is out of date
at the domain controller.
At line:1 char:1

  • New-NetFirewallRule -PolicyStore localhost
  • CategoryInfo : NotSpecified: (MSFT_NetFirewallRule:root/standardcimv2/MSF
    T_NetFirewallRule) [New-NetFirewallRule], CimException
  • FullyQualifiedErrorId : Windows System Error 1397,New-NetFirewallRule

Works for me. What is the OS and PowerShell version you have ?

OS : Win 10 Version 1809 , Powershell : 1.5, these are relatively new versions, the cmd should’ve worked.

Ok. One basic thing to check is whether you are running PowerShell with elevated permissions or not. PowerShell should be running with administrator privileges to do this operation.

It is running with admin privilege.