How do I run a Powershell script from PHP

时光总嘲笑我的痴心妄想 提交于 2019-12-20 06:22:13

问题


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\new.csv") 

php code

<?php
if(isset($_POST['updateDHCP'])){
        shell_exec('powershell.exe -command C:\wamp64\www\DhcpLeasesExport1.ps1');
    }
?>

来源:https://stackoverflow.com/questions/53393645/how-do-i-run-a-powershell-script-from-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!