-
-
Notifications
You must be signed in to change notification settings - Fork 546
Expand file tree
/
Copy pathcheck-firewall.ps1
More file actions
executable file
·31 lines (30 loc) · 761 Bytes
/
check-firewall.ps1
File metadata and controls
executable file
·31 lines (30 loc) · 761 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<#
.SYNOPSIS
Checks the firewall status
.DESCRIPTION
This PowerShell script queries the status of the firewall and prints it to the console.
.EXAMPLE
PS> ./check-firewall.ps1
✅ Firewall is on
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
try {
if ($IsLinux) {
Write-Host "✅ Firewall " -noNewline
& sudo ufw status
} else {
$enabled = (Get-ItemProperty 'HKLM:\SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile').EnableFirewall
if ($enabled) {
Write-Host "✅ Firewall is on"
} else {
Write-Host "⚠️ Firewall is OFF"
}
}
exit 0 # success
} catch {
"⚠️ ERROR: $($Error[0]) (script line $($_.InvocationInfo.ScriptLineNumber))"
exit 1
}