Hi mates, I need your help, thanks to anyone who can write some suggestions here.
My goal is to test a TCP port on a remote device, if it doesn’t work it will execute a command to filter out the ICMP (ping) reply till the TCP will answer again (the device will fail to ping and reboot itself, the TCP will become available again). I think I can use Powershell but as a newbie I don’t know how to implement the script commands.
I figured out I can use for example test-netconnection -computername 192.168.0.1 -port 80 for example, but how can I anaylze the result and depending on it execute the next command?
my goal is to execute one of those lines:
New-NetFirewallRule -DisplayName “Test block this IP” -Direction Inbound -RemoteAddress 192.168.0.102 -Action Block in case the TCP test fail
Remove-NetFirewallRule -DisplayName “Test block this IP” in case the TCP test succeed.
I need to schedule this every minute, for every IP I need to test i can create a different script file, I can use the windows schedule but how I can execute the script? Also I have to execute it with administrator privileges.
Thank you a lot!