mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
37 lines
No EOL
1.2 KiB
PowerShell
37 lines
No EOL
1.2 KiB
PowerShell
<#
|
|
# If some informations are missing, it could happen that
|
|
# we are unable to create a Performance Counter.
|
|
# In this case we will use this Null Object, containing
|
|
# the same member functions but allowing us to maintain
|
|
# stability without unwanted exceptions
|
|
#>
|
|
function New-IcingaPerformanceCounterNullObject()
|
|
{
|
|
param(
|
|
[string]$FullName = '',
|
|
[string]$ErrorMessage = ''
|
|
);
|
|
|
|
$pc_instance = New-Object -TypeName PSObject;
|
|
$pc_instance | Add-Member -membertype NoteProperty -name 'FullName' -value $FullName;
|
|
$pc_instance | Add-Member -membertype NoteProperty -name 'ErrorMessage' -value $ErrorMessage;
|
|
|
|
$pc_instance | Add-Member -membertype ScriptMethod -name 'Name' -value {
|
|
return $this.FullName;
|
|
}
|
|
|
|
$pc_instance | Add-Member -membertype ScriptMethod -name 'Value' -value {
|
|
[hashtable]$ErrorMessage = @{};
|
|
|
|
$ErrorMessage.Add('value', $null);
|
|
$ErrorMessage.Add('sample', $null);
|
|
$ErrorMessage.Add('help', $null);
|
|
$ErrorMessage.Add('type', $null);
|
|
$ErrorMessage.Add('error', $this.ErrorMessage);
|
|
|
|
return $ErrorMessage;
|
|
}
|
|
|
|
return $pc_instance;
|
|
}
|
|
|