-
-
Save p0w3rsh3ll/e7b9768cc3d364915893 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#region WFProfile | |
Script ApplyFirewallProfile { | |
GetScript = { | |
@{ | |
GetScript = $GetScript | |
SetScript = $SetScript | |
TestScript = $TestScript | |
Result = (Get-NetFirewallProfile -All | Select Name,Enabled,Default*) | |
} | |
} | |
SetScript = { | |
Set-NetFirewallProfile -All -Enabled 'True' -DefaultInboundAction 'Block' -DefaultOutboundAction 'Allow' | |
} | |
TestScript = { | |
$local:problem = $false | |
Get-NetFirewallProfile -All | ForEach-Object { | |
if (-not($_.Enabled)) { | |
Write-Verbose "Firewall profile $($_.Name) is not Enabled" | |
$local:problem = $true | |
} | |
if ($_.DefaultInboundAction -ne 'Block') { | |
Write-Verbose "Firewall profile $($_.Name) Default Inbound Action is not Block" | |
$local:problem = $true | |
} | |
if ($_.DefaultOutboundAction -ne 'Allow') { | |
Write-Verbose "Firewall profile $($_.Name) Default Outbound Action is not Allow" | |
$local:problem = $true | |
} | |
} | |
if ($local:problem) { | |
Write-Verbose 'Returning false' | |
return $false | |
} else { | |
Write-Verbose 'Returning true' | |
return $true | |
} | |
} | |
DependsOn = '[xFirewall]Firewall-WINRM-HTTP-In-TCP' | |
} | |
#endregion WFProfile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment