Setup: Computer with PowerShell installed

Problem: You need to check the firewall status from a script, for a local or a remote server.


filter global:get-firewallstatus ([string]$computer = $env:computername)
	if ($_) { $computer = $_ }

	$HKLM = 2147483650

	$reg = get-wmiobject -list -namespace root\default -computer $computer | where-object { $ -eq "StdRegProv" }
	$firewallEnabled = $reg.GetDwordValue($HKLM, "System\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile","EnableFirewall")


get-firewallstatus [<computername>]

Tip 1: Use Run As to open a PowerShell session with an administrative user
Tip 2: Get status for all computer from AD with

Get-QADComputer | select-object -property @{n='Name';e={$}},@{n='FirewallStatus';e={get-firewallstatus $}} 

Leave a Reply

Your email address will not be published. Required fields are marked *