param(
    [string]$ListenAddress = "0.0.0.0",
    [int]$Port = 8010,
    [string]$RuleName = "MyIntranetApp-8010"
)

$ErrorActionPreference = "Stop"

netsh interface portproxy delete v4tov4 listenport=$Port listenaddress=$ListenAddress | Out-Null

$existingRule = Get-NetFirewallRule -DisplayName $RuleName -ErrorAction SilentlyContinue
if ($existingRule) {
    Remove-NetFirewallRule -DisplayName $RuleName | Out-Null
}

Write-Host "Removed portproxy and firewall rule for port $Port" -ForegroundColor Yellow
