Want to understand why Powershell parameters are in some circumstances not functioning

108 views Asked by At

I am aiming to list all available firewall rules by given filters and quite new to Powershell.

Observed a strange behavior which led me asking if there is something hidden that I am not aware of. I may use Pipes to accomplish the same, but I am interested in the reason to understand if there is something that.

Get-NetFirewallRule -DisplayGroup n*

functions as expected

Get-NetFirewallRule -DisplayName n*

functions as expected

But when I am adding/combining -Enabled True the DisplayName is generating such an error message where DisplayGroup is generating a result.

Parameter set cannot be resolved using the specified named parameters.

  • Get-NetFirewallRule -DisplayName n* -Enabled True
Get-NetFirewallRule -Enabled True | ? DisplayName -like nsc*

is working

PS Version '5.1.177' on a Windows 10 Machine.

1

There are 1 answers

0
alexzelaya On

This should work:

Get-NetFirewallRule | ? {($_.DisplayName -like "nsc*") -and ($_.Enabled -eq $true)}