Windows Firewall Rules

Published: Dec 7, 2021 by Bertland Hope

This scanner returns Windows Firewall Rule information. Requires Windows Server 2012/Windows 8 or higher.

Parameters

-Enabled

Returns only enabled rules if used.

[cmdletBinding()]
param(
	[parameter()]
	[switch]
	$Enabled
)

process {
	
	if ([version](Get-CimInstance Win32_OperatingSystem).Version -lt 6.3.0) {
		throw "This scanner is only available on Server 2012/Windows 8 or higher"
	}
	
	$Properties = @(
		"Name"
		"DisplayName"
		"Description"
		"Profile"
		"Direction"
		"Action"
	)

	switch ($Enabled) {
		$true {
			Get-NetFirewallRule -PolicyStore ActiveStore -PolicyStoreSourceType GroupPolicy,Local -Enabled True | Select-Object $Properties
		}
		$false {
			$Properties += @{Name = "Enabled"; Expression = { [System.Convert]::ToBoolean([String]$_.Enabled) } }
			Get-NetFirewallRule -PolicyStore ActiveStore -PolicyStoreSourceType GroupPolicy,Local | Select-Object $Properties
		}
	}

}

Share

Latest News

10 Ways the ICT Performance Boost for Vision 2030 Jamaica Can Save You Money!
10 Ways the ICT Performance Boost for Vision 2030 Jamaica Can Save You Money!

10 Ways the ICT Performance Boost for Vision 2030 Jamaica Can Save You Money

What is a Constellation?
What is a Constellation?

What is a Constellation?

How are Pearls formed?
How are Pearls formed?

How are Pearls formed?

Chicken Back Gravy and Such Delights: Life Lessons From My Journey

Chicken Back Gravy and Such Delights: Life Lessons From My Journey

By Donna P. Hope

From $6.74

Inna Di Dancehall: Popular Culture And the Politics of Identity in Jamaica

Inna Di Dancehall: Popular Culture And the Politics of Identity in Jamaica

Donna P. Hope

From $22.96