[CmdletBinding()]
param(
    [uint16]$Port = 4001,
    [string]$TaskName = "FreedomNetBootstrapNode"
)

$ErrorActionPreference = "Stop"
Set-StrictMode -Version Latest

if (Get-ScheduledTask -TaskName $TaskName -ErrorAction SilentlyContinue) {
    Unregister-ScheduledTask -TaskName $TaskName -Confirm:$false
}

$firewallRuleName = "FreedomNet Bootstrap UDP $Port"
Get-NetFirewallRule -DisplayName $firewallRuleName -ErrorAction SilentlyContinue |
    Remove-NetFirewallRule -ErrorAction SilentlyContinue

Write-Host "FreedomNet bootstrap node task removed."
