Powershell remote execution with php exec function -
i trying run powershell command on remote computer with php script.
i have no trouble execution local powershell scripts. example, successful executed following code:
exec("powershell -command c:\wamp\www\pstest.ps1", $output, $return_var);
output: "hello world", return code: 0
when execute following command prompt have no issues.
powershell -command invoke-command -computername computer.servername.local c:\wamp\www\pstest.ps1
output: "hello world", return code: 0
however, when try execute same code within php script fails.
exec("powershell -command invoke-command -computername computer.servername.local c:\wamp\www\pstest.ps1", $output, $return_var);
output: "", return code: 1
make sure account service running under has admin rights on target system. should fine if personal project @ home. may have rethink things if on corporate system.
Comments
Post a Comment