Module: check_mk
Branch: master
Commit: 274854ab2e50fff7d8bd7419332d94e1f668b847
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=274854ab2e50ff…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Aug 18 17:18:55 2011 +0200
windows check_mk_agent now supports direct execution of powershell scripts
---
agents/windows/check_mk_agent.cc | 18 ++++++++++++++++++
agents/windows/check_mk_agent.exe | Bin 96768 -> 97280 bytes
2 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/agents/windows/check_mk_agent.cc b/agents/windows/check_mk_agent.cc
index a8ccabc..425b1e1 100755
--- a/agents/windows/check_mk_agent.cc
+++ b/agents/windows/check_mk_agent.cc
@@ -1075,6 +1075,24 @@ char *add_interpreter(char *path, char *newpath)
snprintf(newpath, 256, "cscript.exe //Nologo %s", path);
return newpath;
}
+ else if (!strcmp(path + strlen(path) - 5, ".ps1\"")) {
+ // Same for the powershell scripts. Add the powershell interpreter.
+ // To make this work properly two things are needed:
+ // 1.) The powershell interpreter needs to be in PATH
+ // 2.) The execution policy needs to allow the script execution
+ // -> Get-ExecutionPolicy / Set-ExecutionPolicy
+ // Another ugly thing: The commandline syntax of the interpreter.
+ // we need to replace the quotes round the path
+ // and put the path into single quotes oO.
+
+ // Strip the quotes round the string
+ char tmppath[256];
+ strcpy(tmppath, ++path);
+ tmppath[strlen(tmppath) - 1] = '\0';
+
+ snprintf(newpath, 256, "powershell.exe -NoLogo -ExecutionPolicy RemoteSigned
\"& \'%s\'\"", tmppath);
+ return newpath;
+ }
else
return path;
}
diff --git a/agents/windows/check_mk_agent.exe b/agents/windows/check_mk_agent.exe
index edf623a..fcec366 100755
Binary files a/agents/windows/check_mk_agent.exe and b/agents/windows/check_mk_agent.exe
differ