PoshCode Archive  Artifact [4659777c91]

Artifact 4659777c91057a3fe7ada8286b529335efd0ef0142557a05383c597c05b1cf49:

  • File Get-FirewallStatus.ps1 — part of check-in [95e5d81cae] at 2018-06-10 14:24:42 on branch trunk — Returns $true if the Windows Firewall is enabled, $false if it is disabled. (user: rfoust size: 819)

# 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)
	}