1

I noticed that the PowerShell New-NetFirewallRule cmdlet does not behave like I expected. When calling the commandlet repeatedly, it will create multiple entries with the same name.

For example, when running this command twice New-NetFirewallRule -DisplayName "Website" -Direction Inbound -LocalPort 80 -Protocol TCP -Action Allow, will give two of the same firewall entries.

Should commands with the New verb not fail when the resource already exists?

When New-NetFirewallRule retuns an object with the firewall rule, Set-NetFirewallRule returns nothing.

Running Set-NetFirewallRule does not work for creating a new rule. It will raise an error which says that the resource does not exist. I expected a Set verb updates or creates the resource.

Using PowerShell 5.1 on Windows Server 2016

1 Answer 1

1

note that "DisplayName" is not the same as "Name" parameter, name must be unique, display name can repeat it self.

You are using DisplayName so it's not an error, try it with Name and you'll get what you want. an Error of duplicate entry.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .