Invoke-IcingaCheckCPU performance data gets swallowed

Hello, I’ve got the problem, that I do not get any performance data when issue a check with icinga2

I’ve got the following implemented:

object CheckCommand "Invoke-IcingaCheckCPU" {
    import "plugin-check-command"
    command = [
        "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
    ]
    timeout = 3m
    arguments += {
        "-C" = {
            order = 0
            value = "Use-Icinga; exit Invoke-IcingaCheckCPU"
        }
        "-Core" = {
            order = 4
            value = "$IcingaCheckCPU_String_Core$"
        }
        "-Critical" = {
            order = 3
            value = "$IcingaCheckCPU_Object_Critical$"
        }
        "-NoPerfData" = {
            order = 99
            value = "$IcingaCheckCPU_Switchparameter_NoPerfData$"
        }
        "-Verbosity" = {
            order = 5
            value = "$IcingaCheckCPU_Int32_Verbosity$"
        }
        "-Warning" = {
            order = 2
            value = "$IcingaCheckCPU_Object_Warning$"
        }
    }
    vars.IcingaCheckCPU_Int32_Verbosity = 0
    vars.IcingaCheckCPU_Object_Critical = "$$null"
    vars.IcingaCheckCPU_Object_Warning = "$$null"
    vars.IcingaCheckCPU_String_Core = "_Total"
    vars.IcingaCheckCPU_Switchparameter_NoPerfData = false
}
apply Service "WinCpu" {
  import "generic-agent-service"
  notes_url = WikiBaseURL + host.vars.service.notes_url + "WinCpu"
  check_command = "Invoke-IcingaCheckCPU"
  vars.IcingaCheckCPU_Object_Warning = "75"
  vars.IcingaCheckCPU_Object_Critical = "85"
  command_endpoint = host.vars.client_endpoint
  assign where host.vars.os == "Windows" && "noNSClient" in host.vars.features
}

When I issue the check on the windows powershell on he windows host, I do get performance data out:
powershell -C { Use-Icinga; Invoke-IcingaCheckCPU -Warning 75 -Critical 85 -Verbosity 2; }

What am I doing wrong, and why are the performance data values swallowed during the transfer

Thanks from sdohn

After I had modified it accordingly, the check now works as desired with the performance data.

object CheckCommand "PowerShell Base" {
    import "plugin-check-command"
    command = [
        "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
    ]
    timeout = 3m
    arguments += {
        "-ExecutionPolicy" = {
            order = -1
            value = "$IcingaPowerShellBase_String_ExecutionPolicy$"
        }
        "-NoLogo" = {
            order = -2
            set_if = "1"
        }
        "-NoProfile" = {
            order = -3
            set_if = "1"
        }
    }
    vars.IcingaPowerShellBase_String_ExecutionPolicy = "ByPass"
}
object CheckCommand "Invoke-IcingaCheckCPU" {
    import "PowerShell Base"

    arguments += {
        "-C" = {
            order = 0
            value = "try { Use-Icinga -Minimal; } catch { Write-Output 'The Icinga PowerShell Framework is either not installed on the system or not configured properly. Please check https://icinga.com/docs/windows for further details'; Write-Output 'Error:' $$($$_.Exception.Message)Components:`r`n$$( Get-Module -ListAvailable 'icinga-powershell-*' )`r`n'Module-Path:'`r`n$$($$Env:PSModulePath); exit 3; }; Exit-IcingaExecutePlugin -Command 'Invoke-IcingaCheckCPU' "
        }
        "-Core" = {
            order = 4
            set_if = "var str = macro(\"$IcingaCheckCPU_String_Core$\"); if (len(str) == 0) { return false; }; return true;"
            value = {{
                var str = macro("$IcingaCheckCPU_String_Core$");
            var argLen = len(str);
            
            if (argLen == 0) {
                return;
            }
            
            if (argLen != 0 && str.substr(0,1) == "'" && str.substr(argLen - 1, argLen) == "'") {
                return str;
            }
            
            return ("'" + str + "'");
            }}
        }
        "-Critical" = {
            order = 3
            value = "$IcingaCheckCPU_Object_Critical$"
        }
        "-NoPerfData" = {
            order = 99
            set_if = "$IcingaCheckCPU_Switchparameter_NoPerfData$"
        }
        "-ThresholdInterval" = {
            order = 100
            set_if = "var str = macro(\"$IcingaCheckCPU_String_ThresholdInterval$\"); if (len(str) == 0) { return false; }; return true;"
            value = {{
                var str = macro("$IcingaCheckCPU_String_ThresholdInterval$");
            var argLen = len(str);
            
            if (argLen == 0) {
                return;
            }
            
            if (argLen != 0 && str.substr(0,1) == "'" && str.substr(argLen - 1, argLen) == "'") {
                return str;
            }
            
            return ("'" + str + "'");
            }}
        }
        "-Verbosity" = {
            order = 5
            value = "$IcingaCheckCPU_Int32_Verbosity$"
        }
        "-Warning" = {
            order = 2
            value = "$IcingaCheckCPU_Object_Warning$"
        }
    }
    vars.IcingaCheckCPU_Switchparameter_NoPerfData = false
}
apply Service "WinCpu" {
  import "generic-agent-service"
  notes_url = WikiBaseURL + host.vars.service.notes_url + "WinCpu"
  check_command = "Invoke-IcingaCheckCPU"
  vars.IcingaCheckCPU_Object_Warning = "75"
  vars.IcingaCheckCPU_Object_Critical = "85"
  vars.IcingaCheckCPU_Switchparameter_NoPerfData = false
  command_endpoint = host.vars.client_endpoint
  assign where host.vars.os == "Windows" && "noNSClient" in host.vars.features
}