Adds support to securely fetch elements from hashtables with default values

This commit is contained in:
Christian Stein 2020-03-27 16:36:25 +01:00
parent 7dce37717a
commit 699137a97c

View 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];
}