2019-11-03 13:22:28 -05:00
|
|
|
function Get-IcingaFirewallConfig()
|
|
|
|
|
{
|
|
|
|
|
param(
|
|
|
|
|
[switch]$NoOutput
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
[bool]$LegacyFirewallPresent = $FALSE;
|
|
|
|
|
[bool]$IcingaFirewallPresent = $FALSE;
|
|
|
|
|
|
|
|
|
|
$LegacyFirewall = Start-IcingaProcess -Executable 'netsh' -Arguments 'advfirewall firewall show rule name="Icinga 2 Agent Inbound by PS-Module"';
|
|
|
|
|
|
|
|
|
|
if ($LegacyFirewall.ExitCode -eq 0) {
|
|
|
|
|
if ($NoOutput -eq $FALSE) {
|
2020-05-13 10:53:15 -04:00
|
|
|
Write-IcingaConsoleWarning 'Legacy firewall configuration has been detected.';
|
2019-11-03 13:22:28 -05:00
|
|
|
}
|
|
|
|
|
$LegacyFirewallPresent = $TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$IcingaFirewall = Start-IcingaProcess -Executable 'netsh' -Arguments 'advfirewall firewall show rule name="Icinga Agent Inbound"';
|
|
|
|
|
|
|
|
|
|
if ($IcingaFirewall.ExitCode -eq 0) {
|
|
|
|
|
if ($NoOutput -eq $FALSE) {
|
2020-05-13 10:53:15 -04:00
|
|
|
Write-IcingaConsoleNotice 'Icinga firewall is present.';
|
2019-11-03 13:22:28 -05:00
|
|
|
}
|
|
|
|
|
$IcingaFirewallPresent = $TRUE;
|
|
|
|
|
} else {
|
|
|
|
|
if ($NoOutput -eq $FALSE) {
|
2020-05-13 10:53:15 -04:00
|
|
|
Write-IcingaConsoleError 'Icinga firewall is not present';
|
2019-11-03 13:22:28 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return @{
|
|
|
|
|
'LegacyFirewall' = $LegacyFirewallPresent;
|
|
|
|
|
'IcingaFirewall' = $IcingaFirewallPresent;
|
|
|
|
|
}
|
|
|
|
|
}
|