T
T
TechNOIR2017-08-22 13:43:40
PHP
TechNOIR, 2017-08-22 13:43:40

Powershell+PHP. How to run a script in PHP?

Good afternoon.
I study the interaction of Php with Powershell
I try on the simplest script:

<?php
$query = shell_exec("powershell.exe -File E:\test.ps1");
echo $query; 
?>

For example, "Test-Connection Server" is stored in test.ps1 script. It is
necessary that the received response in Powershell returns to the Php page, but in response there is only a blank sheet ...
Please tell me some solution to this problem .. Not necessarily shell_exec. There may be other options?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vadim Zarazhevsky, 2017-08-22
@Chelbeh

You may have an error while executing the command, for example, the shell is disabled for security reasons, and error output is not enabled, which results in a "white sheet". Try turning on error display before the code:

error_reporting(E_ALL);
ini_set('display_errors', 1);

A
azarij, 2017-08-22
@azarij

theboywonder.co.uk/2012/07/29/executing-powershell...
in theory, there you need to write code for the page that will return and populate it through powershell variables.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question