2023-10-31 12:05:32 +01:00
|
|
|
|
<#
|
2023-01-06 21:55:52 +01:00
|
|
|
|
.SYNOPSIS
|
2023-04-11 10:48:59 +02:00
|
|
|
|
Checks the firewall status
|
2023-01-06 21:55:52 +01:00
|
|
|
|
.DESCRIPTION
|
2023-01-23 14:04:23 +01:00
|
|
|
|
This PowerShell script queries the status of the firewall and prints it.
|
2023-01-06 21:55:52 +01:00
|
|
|
|
.EXAMPLE
|
2023-08-06 21:35:36 +02:00
|
|
|
|
PS> ./check-firewall.ps1
|
2023-01-12 20:45:19 +01:00
|
|
|
|
✅ Firewall enabled
|
2023-01-06 21:55:52 +01:00
|
|
|
|
.LINK
|
|
|
|
|
https://github.com/fleschutz/PowerShell
|
|
|
|
|
.NOTES
|
|
|
|
|
Author: Markus Fleschutz | License: CC0
|
|
|
|
|
#>
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
if ($IsLinux) {
|
2023-01-12 20:45:19 +01:00
|
|
|
|
Write-Host "✅ Firewall " -noNewline
|
|
|
|
|
& sudo ufw status
|
2023-01-06 21:55:52 +01:00
|
|
|
|
} 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
|
2023-01-12 20:45:19 +01:00
|
|
|
|
}
|