none
output verbose when executing PowerShell script from php RRS feed

  • Question

  • when running the below script

    Main command :

    Invoke-Command -ComputerName $remoteServer -ScriptBlock {$VerbosePreference='Continue'; & $using:scriptToRun -userName $email}
    

    when running the command line from the PowerShell console everything works fine, i even get verbose outputs that i have muted the, even though the $host = ServerRemoteHost

    the above command is in the remoteDBDeploy.ps1 file. which i am trying to run it using PHP with

    $powershell = 'PowerShell.exe -NoProfile -Command "& {Start-Process PowerShell.exe -ArgumentList \'-NoProfile -ExecutionPolicy RemoteSigned -File "c:\test\ps1\remoteDBDeploy.ps1"\' -Verb RunAs -verbose}" ';
    shell_exec("$powershell");

    but when i run it using my php line, i don't see any verbose outputs.

    i am using Start-Transcript to log all the actions that are made during the script run, i need those NEEDED verbose messages, and not all verbose message on all commands ( needed and not needed ones ).

    i think it is something related that if the console window is hidden it is not outputting any verbose messages. and since i am running the command from a console it is outputting the verbose.

    any suggestions how can i make it work.

    • Edited by Vagho Wednesday, December 14, 2016 11:01 AM
    Wednesday, December 14, 2016 7:16 AM

Answers

  • i think it is something related that if the console window is hidden it is not outputting any verbose messages. and since i am running the command from a console it is outputting the verbose. 


    If the console is hidden you will not see any console messages.

    Again -  This is not a PHP forum. Running PowerShell under a web site is not really a basic scripting operation.

    It is highly likely that the PHP server will not allow alternate handles to be opened to a file.  PHP developers would know how to alter this behavior.


    \_(ツ)_/


    • Edited by jrv Wednesday, December 14, 2016 7:38 PM
    • Marked as answer by Vagho Thursday, December 15, 2016 9:37 AM
    Wednesday, December 14, 2016 7:37 PM

All replies

  • Somewhere there is a patch that needs to be applied to the remote server.

    https://support.microsoft.com/en-us/kb/3014136


    \_(ツ)_/

    Wednesday, December 14, 2016 7:56 AM
  • it did not help .

    to be more specific, when running that same command line from the PowerShell console everything works fine, i even get verbose outputs that i have muted the, even though the $host = ServerRemoteHost, but when i run it using my php line it is not working.

    i think it is something related that if the console window is hidden it is not outputting any verbose messages. and since i am running the command from a console it is outputting the verbose. 


    • Edited by Vagho Wednesday, December 14, 2016 10:25 AM
    Wednesday, December 14, 2016 10:24 AM
  • Please reread your post. It makes no sense because words are missing or incorrect.

    PHP is not supported by this forum so we cannot help you with your PHP issues.  If verbose works in PowerShell then you will need to post PHP issues in a PHP forum.


    \_(ツ)_/


    • Edited by jrv Wednesday, December 14, 2016 7:34 PM
    Wednesday, December 14, 2016 10:35 AM
  • i think it is something related that if the console window is hidden it is not outputting any verbose messages. and since i am running the command from a console it is outputting the verbose. 


    If the console is hidden you will not see any console messages.

    Again -  This is not a PHP forum. Running PowerShell under a web site is not really a basic scripting operation.

    It is highly likely that the PHP server will not allow alternate handles to be opened to a file.  PHP developers would know how to alter this behavior.


    \_(ツ)_/


    • Edited by jrv Wednesday, December 14, 2016 7:38 PM
    • Marked as answer by Vagho Thursday, December 15, 2016 9:37 AM
    Wednesday, December 14, 2016 7:37 PM