forked from gangstanthony/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGet-Firewall.ps1
More file actions
20 lines (17 loc) · 811 Bytes
/
Get-Firewall.ps1
File metadata and controls
20 lines (17 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
## INFO
# find firewall status of remote computer
function Get-Firewall {
param (
[object]$comps = $env:COMPUTERNAME
)
foreach ($computer in $comps) {
try {
# $status = (gp 'HKLM:\SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile').EnableFirewall
# reg query \\$computer\HKLM\SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile /v EnableFirewall
$status = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $computer).OpenSubKey('SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile').GetValue('EnableFirewall')
[bool]$status
} catch [System.Exception] {
return 'Error'
}
}
}