Fix typo in CheckSum, Added First-Draft/Suggestion/Attempt for Firewall-ProfileCheck

This commit is contained in:
Crited 2019-10-31 16:15:09 +01:00
parent 12c4f87876
commit c2fce7042f
2 changed files with 74 additions and 1 deletions

View file

@ -46,7 +46,7 @@ function Invoke-IcingaCheckCheckSum()
{
param(
[string]$Path = $null,
[ValidateSet]('SHA1', 'SHA256', 'SHA384', 'SHA512', 'MD5')
[ValidateSet('SHA1', 'SHA256', 'SHA384', 'SHA512', 'MD5')]
[string]$Algorithm = 'SHA256',
[string]$Hash = $null,
[switch]$NoPerfData,

View file

@ -0,0 +1,73 @@
<#
.SYNOPSIS
Checks whether a firewall module is enabled or not
.DESCRIPTION
Invoke-IcingaCheckFirewall returns either 'OK' or 'CRITICAL', whether the check matches or not.
More Information on https://github.com/LordHepipud/icinga-module-windows
.FUNCTIONALITY
This module is intended to be used to check the status of a firewall profile.
Based on the match result the status will change between 'OK' or 'CRITICAL'. The function will return one of these given codes.
.EXAMPLE
PS> Invoke-IcingaCheckFirewall -Profile "Domain" -Verbosity 3
[OK] Check package "Firewall profiles" (Match All)
\_ [OK] Firewall Profile Domain is True
| 'firewall_profile_domain'=True;;
0
.EXAMPLE
PS> Invoke-IcingaCheckFirewall -Profile "Domain", "Private" -Verbosity 1}
[OK] Check package "Firewall profiles" (Match All)
| 'firewall_profile_domain'=True;; 'firewall_profile_private'=True;;
0
[array]$Profile,
[bool]$Status = $TRUE,
.PARAMETER Profile
Used to specify an array of profiles to check.
.PARAMETER Status
Used to specify a bool value, which determines, whether the firewall profiles should be enabled or disabled.
-Status $TRUE
translates to enabled, while
-Status $FALSE
translates to disabled.
.INPUTS
System.String
.OUTPUTS
System.String
.LINK
https://github.com/LordHepipud/icinga-module-windows
.NOTES
#>
function Invoke-IcingaCheckFirewall()
{
param(
[array]$Profile,
[bool]$Status = $TRUE,
[switch]$NoPerfData,
[int]$Verbosity = 0
);
if ($Status -eq $TRUE) {
$StatusString = "true"
} else {
$StatusString = "false"
}
$FirewallPackage = New-IcingaCheckPackage -Name 'Firewall profiles' -OperatorAnd -Verbos $Verbosity;
foreach ($singleprofile in $Profile) {
$FirewallData = (Get-NetFirewallProfile -Name $singleprofile)
$FirewallCheck = New-IcingaCheck -Name "Firewall Profile $singleprofile" -Value $FirewallData.Enabled;
$FirewallCheck.CritIfNotMatch($StatusString) | Out-Null;
$FirewallPackage.AddCheck($FirewallCheck)
}
return (New-IcingaCheckResult -Check $FirewallPackage -NoPerfData $NoPerfData -Compile);
}