mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
Adds support to securely fetch elements from hashtables with default values
This commit is contained in:
parent
7dce37717a
commit
699137a97c
1 changed files with 18 additions and 0 deletions
18
lib/core/tools/Get-IcingaHashtableItem.psm1
Normal file
18
lib/core/tools/Get-IcingaHashtableItem.psm1
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
function Get-IcingaHashtableItem()
|
||||||
|
{
|
||||||
|
param(
|
||||||
|
$Hashtable,
|
||||||
|
$Key,
|
||||||
|
$NullValue = $null
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($null -eq $Hashtable) {
|
||||||
|
return $NullValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($Hashtable.ContainsKey($Key) -eq $FALSE) {
|
||||||
|
return $NullValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $Hashtable[$Key];
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue