From 8de71663a3ae3d1a12df9dc9aa82211340e59b97 Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Mon, 19 Aug 2019 12:26:23 +0200 Subject: [PATCH] Added error for missing argument on PerformanceCounters --- .../perfcounter/Show-IcingaPerformanceCounters.psm1 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/core/perfcounter/Show-IcingaPerformanceCounters.psm1 b/lib/core/perfcounter/Show-IcingaPerformanceCounters.psm1 index f78e479..5080aa6 100644 --- a/lib/core/perfcounter/Show-IcingaPerformanceCounters.psm1 +++ b/lib/core/perfcounter/Show-IcingaPerformanceCounters.psm1 @@ -4,9 +4,17 @@ # function Show-IcingaPerformanceCounters() { - param ([string]$CounterCategory); + param ( + [string]$CounterCategory + ); [hashtable]$counters = @{}; + + if ([string]::IsNullOrEmpty($CounterCategory)) { + $counters.Add('error', 'Please specify a counter category'); + return $counters; + } + try { # At first create our Performance Counter object for the category we specified $Category = New-Object System.Diagnostics.PerformanceCounterCategory($CounterCategory);