.net - Delete Firewall Rule Using Powershell on Windows 7 -
i working firewalls on windows 7 box, , want delete, not disable, existing rules, , i'm wondering how this. disable, doing :
function disable-incomingfirewallrule($rulename) {     $firewall = new-object -comobject hnetcfg.fwpolicy2      try     {         $rule = $firewall.rules.item($rulename)         $rule.enabled = $false         write-host "firewal rule disabled"     }     catch     {        write-host -foregroundcolor red "rule not exist"      } but after this, rule still exists, , when run several times, have number of disabled rules, why want delete them.
unfortunately using , of netsecurity module not option, because these work on window 8.
i have search high , low show me how this, have come short. appreciated.
use netsh:
netsh advfirewall firewall delete rule name="$rulename" 
Comments
Post a Comment