-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDRMM-WinFirewall.ps1
31 lines (26 loc) · 1.05 KB
/
DRMM-WinFirewall.ps1
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
### DRMM-WinFirewall
### Disable or enable Windows firewall entirely
### v0.1 - First build
### Created by Lee Mackie - leem@5gn.com.au
$fwStatus = $ENV:Status
Write-Host "-- Current firewall mode:"
Write-Host "Public:" $(Get-NetFirewallProfile -Name Public).Enabled
Write-Host "Private:" $(Get-NetFirewallProfile -Name Private).Enabled
Write-Host "Domain:" $(Get-NetFirewallProfile -Name Domain).Enabled
Write-Host "-- Setting all firewall modes to $fwStatus"
try {
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled $fwStatus
} catch {
Write-host "-- An error was encountered trying to set the firewall mode."
Write-Host "Error: $_"
}
Write-Host "-- New firewall mode:"
Write-Host "Public: " $(Get-NetFirewallProfile -Name Public).Enabled
Write-Host "Private: " $(Get-NetFirewallProfile -Name Private).Enabled
Write-Host "Domain: " $(Get-NetFirewallProfile -Name Domain).Enabled
if ($(Get-NetFirewallProfile).Enabled -eq $fwstatus) {
Write-Host "-- Script ran successfully"
} else {
Write-Host "-- Failed to set firewall mode"
Exit 1
}