-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathExit-IcingaPluginNotInstalled.psm1
37 lines (34 loc) · 1.45 KB
/
Exit-IcingaPluginNotInstalled.psm1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<#
.SYNOPSIS
Tests if a provided command is available on the system and exists
the shell with an Unknown error and a message. Required to properly
handle Icinga checks and possible error displaying inside Icinga Web 2
.DESCRIPTION
Tests if a provided command is available on the system and exists
the shell with an Unknown error and a message. Required to properly
handle Icinga checks and possible error displaying inside Icinga Web 2
.FUNCTIONALITY
Tests if a provided command is available on the system and exists
the shell with an Unknown error and a message. Required to properly
handle Icinga checks and possible error displaying inside Icinga Web 2
.EXAMPLE
PS>Exit-IcingaPluginNotInstalled -Command 'Invoke-IcingaCheckCPU';
.PARAMETER Command
The name of the check command to test for
.INPUTS
System.String
.LINK
https://github.com/Icinga/icinga-powershell-framework
#>
function Exit-IcingaPluginNotInstalled()
{
param (
[string]$Command
);
if ([string]::IsNullOrEmpty($Command)) {
Exit-IcingaThrowException -CustomMessage 'Null-Command' -ExceptionType 'Configuration' -ExceptionThrown $IcingaExceptions.Configuration.PluginNotAssigned -Force;
}
if ($null -eq (Get-Command $Command -ErrorAction SilentlyContinue)) {
Exit-IcingaThrowException -CustomMessage $Command -ExceptionType 'Configuration' -ExceptionThrown $IcingaExceptions.Configuration.PluginNotInstalled -Force;
}
}