I need to enable the firewall in all the company machines and there isnt anydocumentation about used ports so I am planning to use a PowerShell script to log all inbound connections in order to create the required exceptions.
how can I monitor using PowerShell or C# all inbound connections created to my machines? because y has found that there is a Cmdlet that list all the connection to the machine, but I haven’t found a way to select just the inbound connections
there is a way to achieve this?
Why are you not just using the FW software for this?
As for …
You've just stated that you can get all connections, those connection lines should show the FW rule triggered and from your FW software, you already know what rules are ingress / egress.
Filter the on the inbound rules listed to get your dataset.
Then match that up to your all connections dataset.
But all this sounds like you are trying create your own IDS using PS. I would say that is an over engineering effort, since off the shelf tools provide this already.