title: Delete Firewall Rule Using Powershell on Windows 7
body: <p>I am working with Firewalls on a Windows 7 box, and I want to DELETE, not disable, existing rules, and I'm wondering how to do this. To disable, I am doing :</p>
  
  <pre><code>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 does not exist"
  
      }
  </code></pre>
  
  <p>But after this, the rule still exists, and when I run this several times, I will have a number of disabled rules, which is why I want to delete them. </p>
  
  <p>Unfortunately using and of the <code>NetSecurity</code> module is not an option, because these only work on Window 8.</p>
  
  <p>I have search high and low for something to show me how to do this, but have come up short. Any help would be greatly appreciated. </p>