icinga-powershell-framework/lib/config/Test-IcingaPowerShellConfigItem.psm1
2021-09-14 10:07:48 +02:00

40 lines
939 B
PowerShell

<#
.SYNOPSIS
Test if a config entry on an object is already present
.DESCRIPTION
Test if a config entry on an object is already present
.FUNCTIONALITY
Test if a config entry on an object is already present
.EXAMPLE
PS>Test-IcingaPowerShellConfigItem -ConfigObject $PSObject -ConfigKey 'keyname';
.PARAMETER ConfigObject
The custom config object to check for
.PARAMETER ConfigKey
The key which is checked
.INPUTS
System.String
.OUTPUTS
System.Boolean
.LINK
https://github.com/Icinga/icinga-powershell-framework
#>
function Test-IcingaPowerShellConfigItem()
{
param (
$ConfigObject,
$ConfigKey
);
if ($null -eq $ConfigObject -Or [string]::IsNullOrEmpty($ConfigKey)) {
return $FALSE;
}
foreach ($entry in $ConfigObject.PSObject.Properties) {
if ($entry.Name.ToLower() -eq $ConfigKey.ToLower()) {
return $TRUE;
}
}
return $FALSE;
}