Running Powershell command from PHP returns blank page


hi. :-)

i have script :

<?php  $q = shell_exec('powershell get-help');  echo $q;  ?>

this works , gives me output.

but... when change get-help get-vm gives me blank page ouput. have simillar problems other hyper-v cmdlets.

this code 1:

<?php  $q = shell_exec('powershell get-vm');  echo $q;  ?>

this code gives me blank page.

code 2:

<?php  $q = shell_exec('powershell start-vm 'vm1'');  echo $q;  ?>

this code gives me cannot find vm name.

what's problem, change in script or system settings.

note: commands work , gives me output when run cmd

things did:

 1. changed execution policy unrestricted

 2. added 2<&1 @ end of shell_exec.

thanks in advance.

hi,

i think should run powershell adminitrator vms.

start-process "$pshome\powershell.exe" -verb runas -argumentlist '-command "get-vm"'

regards,

yan li


regards, yan li




Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Group Policy Event ID 1058 Error Code 1326 (The user name or password is incorrect)

Suspicious event log Event ID: 4905

DCOM received error "2147746132" from...