Я пытаюсь вызвать команду на powershell в моем сценарии php.Ниже приведен код, который у меня есть.
Код powershell вызывается на удаленной машине:
exec("Powershell.exe -ExecutionPolicy Bypass -Command Invoke-Command -ComputerName computer.domain.net \\Computer.domain.net\ta\Waitandreload.ps1");
Однако это не работает.
Когда я запускаюприведенный ниже код в моем PowerShell (x64 и x86), он отлично работает даже без запуска powershell от имени администратора.
Powershell.exe -ExecutionPolicy Bypass -Command Invoke-Command -ComputerName computer.domain.net \\Computer.domain.net\ta\Waitandreload.ps1
Любая помощь приветствуется.
Ниже приведен код, который у меня есть
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile) && move_uploaded_file($_FILES['mappingfile']['tmp_name'], $uploadmappingfile) && in_array($ext,$allowed) && in_array($mappingext,$allowed))
{
echo "File is valid, and was successfully uploaded.";
/* $query = "INSERT INTO tafileuploadmapping (CustomerName, TicketSheet, MappingSheet)
VALUES('$customername', '$uploadfile', '$uploadmappingfile')";
mysqli_query($db, $query);
//$_SESSION['success'] = "File Now Uploaded";
*/
exec("Powershell.exe -ExecutionPolicy Bypass -Command Invoke-Command -ComputerName computer.domain.net \\computer.domain.net\ta\Waitandreload.ps1",$out,$ret);
echo "running till powershell command";
print_r($out);
echo "</n>";
print_r($ret);
Вывод, который я получаю при этом, выглядит следующим образом:
Файл действителен и был успешно загружен.работает до powershell commandArray () 1