#Requires -RunAsAdministrator
param([int]$Port = 3100)

$ruleName = "Accuracy Retention Evaluation System LAN ($Port)"
Get-NetFirewallRule -DisplayName $ruleName -ErrorAction SilentlyContinue | Remove-NetFirewallRule
New-NetFirewallRule `
    -DisplayName $ruleName `
    -Direction Inbound `
    -Action Allow `
    -Protocol TCP `
    -LocalPort $Port `
    -Profile Domain,Private `
    -RemoteAddress LocalSubnet | Out-Null

Write-Host "LAN access is enabled on TCP port $Port for Domain and Private networks." -ForegroundColor Green
