Skip to content

Commit f6a6abd

Browse files
committed
Fixes possible crashes on Firewall check
1 parent 5323763 commit f6a6abd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

plugins/Invoke-IcingaCheckFirewall.psm1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ function Invoke-IcingaCheckFirewall()
5151
$FirewallPackage = New-IcingaCheckPackage -Name 'Firewall profiles' -OperatorAnd -Verbos $Verbosity;
5252

5353
foreach ($singleprofile in $Profile) {
54-
$FirewallData = (Get-NetFirewallProfile -Name $singleprofile)
55-
$FirewallCheck = New-IcingaCheck -Name "Firewall Profile $singleprofile" -Value $FirewallData.Enabled -Translation @{ 'true' = 'Enabled'; 'false' = 'Disabled'};
54+
$FirewallData = (Get-NetFirewallProfile -Name $singleprofile -ErrorAction SilentlyContinue);
55+
$FirewallCheck = New-IcingaCheck -Name "Firewall Profile $singleprofile" -Value $FirewallData.Enabled -ObjectExists $FirewallData -Translation @{ 'true' = 'Enabled'; 'false' = 'Disabled'};
5656
$FirewallCheck.CritIfNotMatch([string]$Enabled) | Out-Null;
5757
$FirewallPackage.AddCheck($FirewallCheck)
5858
}

0 commit comments

Comments
 (0)