Added error for missing argument on PerformanceCounters

This commit is contained in:
Lord Hepipud 2019-08-19 12:26:23 +02:00
parent 1edcec19a2
commit 47ac91608c

View file

@ -4,9 +4,17 @@
# #
function Show-IcingaPerformanceCounters() function Show-IcingaPerformanceCounters()
{ {
param ([string]$CounterCategory); param (
[string]$CounterCategory
);
[hashtable]$counters = @{}; [hashtable]$counters = @{};
if ([string]::IsNullOrEmpty($CounterCategory)) {
$counters.Add('error', 'Please specify a counter category');
return $counters;
}
try { try {
# At first create our Performance Counter object for the category we specified # At first create our Performance Counter object for the category we specified
$Category = New-Object System.Diagnostics.PerformanceCounterCategory($CounterCategory); $Category = New-Object System.Diagnostics.PerformanceCounterCategory($CounterCategory);