我正在尝试将参数从php脚本传递到Powershell脚本。我可以从Powershell Promt中获取命令。
.\gen.ps1 -countrycode "US" -state "state" -town "town" -org "org" -orgunit "orgunit" -email "user@company.com" -common "common" -altname1 "altname1"
这在Powershell提示符下起作用。
我似乎无法获得我的PHP脚本来运行带有参数的命令。我没有收到任何错误。 我将命令回显到网页上,看起来不错。
powershell ".\gen.ps1" -countrycode "US" -state "state" -town "town" -org "company & com" -orgunit "Servers" -email "test@company.com" -common "test this here" -altname1 "Test"
我正在使用的php命令是
shell_exec("powershell -command \".\\gen.ps1\" -countrycode \"$countrycode\" -state \"$state\" -town \"$town\" -org \"$org\" -orgunit \"$orgunit\" -email \"$email\" -common \"$common\" -altname1 \"$altname1\"");
我还有其他从php运行的powershell命令,例如
$remove = 'powershell "del ./file/fullhtml.php"';
shell_exec($remove);
$remove = 'powershell "del ./file/afull2.php"';
shell_exec($remove);
$remove = 'powershell "move ./file/afull3.php ./file/fullhtml.php"';
shell_exec($remove);
效果很好