variables - Executing powershell script from PHP with arguments -
I'm ending my mind and my pc on it, hopefully someone can help me.
I have a PHP site that needs to execute PowerShell script which is executable and executable.
PHP, which calls .ps1
define ('UpdaterPath', 'C: \\ Artemis \\ DbUpdateUtility1.0.12.2'); ('OutputLocation' updaterPath '\\ Output'.); $ CMD = Updater Path '\\ ArtemisXmlUtil.exe'; $ Action = 'import'; $ Args = '-f' outputLocation; $ PsScriptPath = ' \\ get-process.ps1 '; $ Query = shell_exec ("powershell-command $ psScriptpath -cmd '$ cmd' -action '$ action' -paras '$ args' & lt; NUL");
My .ps1 script is:
param ([string] $ cmd, [string] $ action, [string] $ paras) & amp; $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ From Php, it runs only with $ CMD variables and ignores $ action and $ paras. I tried to configure the variable in all 1 string, but it fails because even the view is not executable.
Full orders look like shouls:
C: \ artemis \ DbUpdateUtility1.0.12.2 \ ArtemisXmlUtil.exe import -fc: \ artemis \ DbUpdateUtility1.0.12. 2 \ Output
Well, it's the same on my own.
The problem is that the command was being executed. "Forcing the parameters to pass in the script to force the power shield correctly, since this command is an executable, so make the whole command as a string and pass it in a single ps1 file And then to convert the ps1 file to use the Incon-Expression command line.
Ultimate ([string] $ CMD) $ ACD = $ CMD
Comments
Post a Comment