# encoding: ascii
# api: powershell
# title: Get-FirewallStatus
# description: Returns $true if the Windows Firewall is enabled, $false if it is disabled.
# version: 0.1
# author: rfoust
# license: CC0
# x-poshcode-id: 836
# x-archived: 2016-03-07T22:52:31
# x-published: 2009-01-31T17:56:00
#
#
# returns true if windows firewall is enabled, false if it is disabled
filter global:get-firewallstatus ([string]$computer = $env:computername)
{
if ($_) { $computer = $_ }
$HKLM = 2147483650
$reg = get-wmiobject -list -namespace root\default -computer $computer | where-object { $_.name -eq "StdRegProv" }
$firewallEnabled = $reg.GetDwordValue($HKLM, "System\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile","EnableFirewall")
[bool]($firewallEnabled.uValue)
}