Powershell command -

I added powershell as a check command via director and when I execute the command it returns an error saying it can’t find the file or directory.

execvpe(C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe) failed: No such file or directory

What is wrong?

The error displays the single \ but if I preview the command config itself it displays the escaped \ in the path.

I’m confused as I see other posts here that show what I have configured working.

1 Like

execvpe is used on Linux, and as such, the service check isn‘t executed on a Windows agent. You can see that by inspecting the check source in Icinga Web’s detail view.

1 Like

How can I get the command to be executed on the windows host and not Linux? I found your postings showing doing this but I get the error above when I try.

Afaik you just need to set the “Run on Agent” option in the service template to yes. Or just create an extra template like service-check-on-agent that sets this option and then import it to your specific check/apply rule.

3 Likes

Right. The howto Windows PowerShell Checks with Icinga2 uses a command_endpoint attribute which is abstracted by the Director within the agent settings.

1 Like

That was it! I can’t beleive I overlooked that setting haha

Also happened in my setup, so maybe it’s worth sharing.

Beware when importing two service templates with differing agent settings in the same service.

In short,

  • If you define two service templates, one with run on agent = yes; the other one with run on agent = no;
  • and if you create a service (standalone or within a service set) importing both of those templates;

then pay attention to the order in which you import them.

If you still want your check to be executed on the (win/linux) agent, the service template with run on agent = yes needs to be the last one you declare in the import field (it will overwrite the values from the previous one(s)).


What use case even leads to this problem?!

One service template is used to set the check command and tresholds and declares run on agent = yes.

The other is used to set some defaults in check execution interval, timeout and so on, which in themselves are actually agent-agnostic.
But, you need to set one strict value – agent yes or no, so for it to be universally applicable, i chose the latter.