duanlei7101
duanlei7101
2018-11-20 13:05
浏览 276

如何从PHP运行Powershell脚本

I wrote one line of powershell script that downloads DHCP lease data. when i run it from powershell it works (exports the data into a csv file). but if i run the same code from php it exports an empty csv file. The powershell script and php code id below.

DhcpServerv4Lease -ComputerName "HAP2000-11" -ScopeId 10.10.10.0 | Select-Object -Property IPAddress, Clientid, Description, HostName | Export-Csv -Path ("C:\wamp64\www
ew.csv") 

php code

<?php
if(isset($_POST['updateDHCP'])){
        shell_exec('powershell.exe -command C:\wamp64\www\DhcpLeasesExport1.ps1');
    }
?>
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

相关推荐