mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 07:10:15 -05:00
37 lines
1.1 KiB
PowerShell
37 lines
1.1 KiB
PowerShell
|
|
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) {
|
||
|
|
Write-Host 'Legacy firewall configuration has been detected.';
|
||
|
|
}
|
||
|
|
$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) {
|
||
|
|
Write-Host 'Icinga firewall is present.';
|
||
|
|
}
|
||
|
|
$IcingaFirewallPresent = $TRUE;
|
||
|
|
} else {
|
||
|
|
if ($NoOutput -eq $FALSE) {
|
||
|
|
Write-Host 'Icinga firewall is not present';
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return @{
|
||
|
|
'LegacyFirewall' = $LegacyFirewallPresent;
|
||
|
|
'IcingaFirewall' = $IcingaFirewallPresent;
|
||
|
|
}
|
||
|
|
}
|