Skip to main content
While it is relatively easy to do something like this

activate "Windows".CommandOut("cmd /c echo Hello World!", $1)
  and it is also possible to run a Powershell script with something like this

activate "Windows".Command( "cmd /c start /wait /b /min %%"%%" powershell -ExecutionPolicy Bypass -Command %%"Write-Output (Hello World)%%" | Out-File temp.txt " )

I have been unable to find a way to use CommandOut to capture Powershell output. Has anybody else encountered and resolved this issue? I have tried Write-Host, Write-Output and a few other variations but it does not appear that Powershell output goes where CommandOut can access it.

------------------------------
Harjit Batra
IT Director
Rocket Forum Shared Account
------------------------------
While it is relatively easy to do something like this

activate "Windows".CommandOut("cmd /c echo Hello World!", $1)
  and it is also possible to run a Powershell script with something like this

activate "Windows".Command( "cmd /c start /wait /b /min %%"%%" powershell -ExecutionPolicy Bypass -Command %%"Write-Output (Hello World)%%" | Out-File temp.txt " )

I have been unable to find a way to use CommandOut to capture Powershell output. Has anybody else encountered and resolved this issue? I have tried Write-Host, Write-Output and a few other variations but it does not appear that Powershell output goes where CommandOut can access it.

------------------------------
Harjit Batra
IT Director
Rocket Forum Shared Account
------------------------------

Hi Harjit,

Have you found a solution for your question. I'm also looking for a solution. I want to capture the output in a variable. If I use Commandout with two parameters (one is command and another one is $variable) the $variable is always null. But the command was executed successfully. I see the powershell window opened for a second and display the output and closed automatically. 



------------------------------
Thanks,
Satheesh MuthuGopal
------------------------------

Hi Harjit,

Have you found a solution for your question. I'm also looking for a solution. I want to capture the output in a variable. If I use Commandout with two parameters (one is command and another one is $variable) the $variable is always null. But the command was executed successfully. I see the powershell window opened for a second and display the output and closed automatically. 



------------------------------
Thanks,
Satheesh MuthuGopal
------------------------------

Hi Satheesh MuthuGopal,

in a previous discussion was already pointed out the only solution for time being is:
- save the result to a temporary file into your powershell script
- use Uniface fileload instruction to load the temporary file and fill your variable

Hope it helps...

Regards,
Gianni



------------------------------
Gianni Sandigliano
IT
------------------------------

Hi Satheesh MuthuGopal,

in a previous discussion was already pointed out the only solution for time being is:
- save the result to a temporary file into your powershell script
- use Uniface fileload instruction to load the temporary file and fill your variable

Hope it helps...

Regards,
Gianni



------------------------------
Gianni Sandigliano
IT
------------------------------

Hi Gianni,

Thanks  a lot for your reply.

It works.!



------------------------------
Thanks,
Satheesh MuthuGopal
------------------------------