Added check-firewall.ps1

This commit is contained in:
Markus Fleschutz 2023-01-06 21:55:52 +01:00
parent f3cc8de619
commit 047ef6526d
2 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,31 @@
<#
.SYNOPSIS
Check the firewall
.DESCRIPTION
This PowerShell script queries and prints firewall details.
.EXAMPLE
PS> ./check-firewall
AMD Ryzen 5 5500U with Radeon Graphics (CPU0, 2100MHz, 31.3°C)
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
try {
if ($IsLinux) {
# TODO
} else {
$enabled = (gp 'HKLM:\SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile').EnableFirewall
if ($enabled) {
Write-Host "✅ Firewall enabled"
} else {
Write-Host "⚠️ Firewall disabled"
}
}
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}

View File

@ -34,6 +34,7 @@
& "$PSScriptRoot/check-pending-reboot.ps1"
" "
& "$PSScriptRoot/write-green.ps1" " N E T W O R K"
& "$PSScriptRoot/check-firewall"
& "$PSScriptRoot/check-ping.ps1"
& "$PSScriptRoot/check-dns.ps1"
& "$PSScriptRoot/check-vpn.ps1"