
tl;drPowershell을 사용하는 경우 Windows 방화벽이 응용 프로그램을 허용하는지 어떻게 확인합니까?
Windows 10을 사용하여 Windows Defender 방화벽을 통해 응용 프로그램이 허용되는지 프로그래밍 방식으로 확인하고 싶습니다. 기본적으로 방화벽 대화 상자를 확인하고 싶습니다.앱이 Windows Defender 방화벽을 통해 통신하도록 허용파워셸을 사용합니다.
python.exe
예를 들어, 에 설치된 프로그램이 있는 경우 C:\Program Files\Python\python.exe
해당 애플리케이션이 다양한 네트워크와 통신할 수 있는지 어떻게 확인할 수 있습니까?도메인,사적인,공공의Powershell 스크립트에서?
답변1
나는 몇 년 전에 이것을 사용했습니다. https://medium.com/@glizzykingdreko/open-a-port-on-windows-firewall-with-a-simple-powershell-script-dc5cc48d013a
스크립트:
[int]$port = 3777
)
$ruleName = "Allow Port $port"
# Check if the rule already exists
$existingRule = Get-NetFirewallRule -DisplayName $ruleName -ErrorAction SilentlyContinue
if ($existingRule) {
Write-Host "Firewall rule '$ruleName' already exists."
} else {
# Create a new inbound rule for the specified port
New-NetFirewallRule -DisplayName $ruleName -Direction Inbound -Action Allow -Protocol TCP -LocalPort $port
Write-Host "Firewall rule '$ruleName' created."
}
그런 다음 .\scriptname.ps1 -port 5000 폴더에서 스크립트를 실행합니다.