2019-11-03 13:22:28 -05:00
|
|
|
function Disable-IcingaFirewall()
|
|
|
|
|
{
|
|
|
|
|
param(
|
|
|
|
|
[switch]$LegacyOnly
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$FirewallConfig = Get-IcingaFirewallConfig -NoOutput;
|
|
|
|
|
|
|
|
|
|
if ($FirewallConfig.LegacyFirewall) {
|
|
|
|
|
$Firewall = Start-IcingaProcess -Executable 'netsh' -Arguments 'advfirewall firewall delete rule name="Icinga 2 Agent Inbound by PS-Module"';
|
|
|
|
|
if ($Firewall.ExitCode -ne 0) {
|
2020-05-13 10:53:15 -04:00
|
|
|
Write-IcingaConsoleError ([string]::Format('Failed to remove legacy firewall: {0}{1}', $Firewall.Message, $Firewall.Error));
|
2019-11-03 13:22:28 -05:00
|
|
|
} else {
|
2020-05-13 10:53:15 -04:00
|
|
|
Write-IcingaConsoleNotice 'Successfully removed legacy Firewall rule';
|
2019-11-03 13:22:28 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($LegacyOnly) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($FirewallConfig.IcingaFirewall) {
|
|
|
|
|
$Firewall = Start-IcingaProcess -Executable 'netsh' -Arguments 'advfirewall firewall delete rule name="Icinga Agent Inbound"';
|
|
|
|
|
if ($Firewall.ExitCode -ne 0) {
|
2020-05-13 10:53:15 -04:00
|
|
|
Write-IcingaConsoleError ([string]::Format('Failed to remove Icinga firewall: {0}{1}', $Firewall.Message, $Firewall.Error));
|
2019-11-03 13:22:28 -05:00
|
|
|
} else {
|
2020-05-13 10:53:15 -04:00
|
|
|
Write-IcingaConsoleNotice 'Successfully removed Icinga Firewall rule';
|
2019-11-03 13:22:28 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|