Skip to content

Instantly share code, notes, and snippets.

@p0w3rsh3ll
Created March 25, 2016 11:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save p0w3rsh3ll/e7b9768cc3d364915893 to your computer and use it in GitHub Desktop.
Save p0w3rsh3ll/e7b9768cc3d364915893 to your computer and use it in GitHub Desktop.
#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