PHP:来自powershell脚本的echo返回参数

时间:2017-06-22 23:10:30

标签: php powershell

我想通过PHP执行powershell脚本,并希望在PHP变量中返回参数。因此,对于测试,我试图从powershell脚本中获取Windows版本。

<?php 

exec("C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe  gwmi     win32_operatingsystem | % caption",$output );

echo( '<pre>' );
var_dump( $output );
echo( '</pre>' );

?>

输出:

C:\wamp64\www\py\indexPHP.php:6:
array (size=0)
  empty

但它返回一个空数组。

1 个答案:

答案 0 :(得分:0)

您的电话不正确。

exec("C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -Command (GWMI Win32_OperatingSystem).Caption", $Output);