Managing Windows firewall with PowerShell

To check the status of the Windows firewall with PowerShell, type the following:


$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
        } 
    };

To disable the Windows firewall for all profiles with PowerShell, type the following:
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False

Tags: 

You might also be interested in...