Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#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