Powershell: 방화벽이 활성화되어 있는지 확인하세요(프로필 아님).

Powershell: 방화벽이 활성화되어 있는지 확인하세요(프로필 아님).

Windows 10에서 방화벽 상태를 표시하는 방식이 약간 불편합니다. 다음 정보를 얻기 위해 Windows 10 및 Server 2016 장치를 감사하려고 합니다.

  1. Windows 방화벽이 활성화되어 있습니까? [작동 안함]
  2. 프로필 3개가 모두 활성화되어 있나요? [일하고 있는]
  3. 타사 방화벽이 활성화되어 있습니까? [일하고 있는]

이 화면에서는 모든 것이 활성화되어 있고 정상인 것처럼 보입니다. 건강한 FW 프로필

그러나 한 수준 위로 올라가면 다음과 같은 메시지가 표시됩니다('켜기'를 클릭해도 아무 작업도 수행되지 않음). BitDefender로 인해 WF가 비활성화되었습니다.

여기에서 세 가지 프로필에 대한 레지스트리 키를 확인하면 모두 활성화되어 있음을 알 수 있습니다. "HKLM:\SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy"그러나 Windows 방화벽이 비활성화되어 있기 때문에 실제로는 '활성화'되지 않습니다.

이 작은 조각은 장치에서 타사 방화벽을 감지합니다.

$firewalls= @(Get-WmiObject -Namespace $securityCenterNS -class FirewallProduct -ErrorAction Stop)

if($firewalls.Count -eq 0){

    Write-Output "No third party firewall installed."

}else{ 

    $firewalls | Foreach-Object {                       
        [int]$productState=$_.ProductState
        $hexString=[System.Convert]::toString($productState,16).padleft(6,'0')
        $provider=$hexString.substring(0,2)
        $realTimeProtec=$hexString.substring(2,2)
        $definition=$hexString.substring(4,2)

        "Product Name : {0}."     -f $_.displayName
        "Service Type : {0}."     -f $SecurityProvider[[String]$provider]
        "State        : {0}.`n`n" -f $RealTimeBehavior[[String]$realTimeProtec]
    }
}

<# OUTPUT:
Product Name : Bitdefender Firewall
Service Type : AntiVirus
State        : ON
#>

질문: Windows 방화벽(프로필뿐만 아니라)이 실제로 활성화되었는지 비활성화되었는지 어떻게 알 수 있습니까? 레지스트리에서 찾아야 하는 특정 값이 있습니까? FW가 실제로 켜져 있는지 여부를 빠르게 알려주는 커맨드렛이 아래에 있습니까?

방화벽 커맨드렛

답변1

그만큼윈도우 방화벽OS에 서비스로 설치됩니다. 전역적으로 활성화 또는 비활성화되었는지 확인하려면 상태가 "실행 중"인지 "중지"인지 확인해야 합니다.

파워셸

$FWService = (Get-Service | ?{$_.Name -eq "mpssvc"});
$FWService | %{
    If($_.Status -eq "Running"){
        Write-Host "The $($_.DisplayName) service is running." -Foregroundcolor Green
        }Else{
        Write-Host "The $($_.DisplayName) service is stopped." -Foregroundcolor Red
        }
    };

게다가 다음과 같이Windows 방화벽 프로필라고 명시되어 있습니다. . .

  • Windows 방화벽은 도메인, 개인, 공용이라는 세 가지 방화벽 프로필을 제공합니다. 도메인 프로필은 호스트 시스템이 도메인 컨트롤러에 인증할 수 있는 네트워크에 적용됩니다. 개인 프로필은 사용자가 할당한 프로필이며 개인 또는 홈 네트워크를 지정하는 데 사용됩니다. 마지막으로 기본 프로필은 공개 프로필로 커피숍, 공항, 기타 위치의 Wi-Fi 핫스팟과 같은 공용 네트워크를 지정하는 데 사용됩니다.

즉, 이 세 가지 프로필 수준에서도 Windows 방화벽을 비활성화하거나 활성화할 수 있으므로 여기에서 활성화 또는 비활성화되었는지 확인하려면 이러한 프로필의 상태를 확인해야 합니다.

파워셸

$FWProfiles = (Get-NetFirewallProfile);
Write-Host "Windows Firewall Profile Statuses" -Foregroundcolor Yellow;
$FWProfiles | %{
    If($_.Enabled -eq 1){
        Write-Host "The Windows Firewall $($_.Name) profile is enabled"  -Foregroundcolor Green
        }Else{
        Write-Host "The Windows Firewall $($_.Name) profile is disabled" -Foregroundcolor Red
        } 
    };

추가 리소스

관련 정보