netsh show rules filtered by local port -


the commande here allow show rules,

    netsh advfirewall firewall show rule dir=in name=all 

i filter

  • rules related port 445.
  • currently enabled rules.

i read documentation , see example, optional option [dir=in|out] not documented.

how can achieved? documentation undocumented possibilities

i may use vb script or powershell 2.0 if required.

these 2 undocumented options know of:

dir (direction) - in or out

status - enabled or disabled

we can build netsh query gets close , missing port part:

netsh advfirewall firewall show rule status=enabled name=all 

we can port requirement using powershell's select-string (disclaimer i'm not @ regex there might better one, seems work)

select-string -pattern "(localport.*445)|(localport.*any)" -context 9,4 

the select-string matches specific rule 445, , rules apply port. context argument display rest of rule (otherwise we'll localport line)

the final command ends being

netsh advfirewall firewall show rule status=enabled name=all | select-string -pattern "(localport.*445)|(localport.*any)" -context 9,4 

this works me, let me know if gives issues or want else.


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -