HexCon is coming to NYC. Catch the early-bird price before the time's up! Book me a spot

Powershell scripts do not show outputSolved

Participant
Discussion
3 years ago

Was testing out the remote scripting feature of Windows. When I execute a batch script, I could see the output in Hexnode but when I ran a powershell script, there was no output.

Replies (5)

Marked SolutionPending Review
Participant
3 years ago
Marked SolutionPending Review

Haven’t tested out the remote scripting feature yet. Where exactly can we see the output?

Marked SolutionPending Review
Participant
3 years ago
Marked SolutionPending Review

The output is in action history. This show output is visible only when I run a .bat script.

Marked SolutionPending Review
Hexnode Expert
3 years ago
Marked SolutionPending Review

Hello Ybeees,

Thank you for reaching out to us. It looks like there may be an issue with the script that you were running. You will be able to execute both batch and PowerShell scripts from the Hexnode portal using the Custom Script feature. However, you will only obtain an output if the script contains a print command in it.
We have cumulated some troubleshooting points to help you run your scripts in the correct format:

  1. Initially, you can run your script manually on your Windows device to check whether the script is producing the expected output. If the script is not executed successfully, you may have to manually check the commands to correct your script.
  2. Running a simple batch script will always display the option Show Output. This is because a batch script will print all the commands in it unless you add the command @echo off. The output that is displayed when you click Show Output might just be the commands in the file.
  3. Unlike batch script, a PowerShell script will not print its commands. If you want to see the option Show Output, include the command Write-Host or Write-Output accompanied by the text you want to print.
  4. The absence of Show Output after executing a PowerShell script does not always indicate that the script has failed.

Hope this helps you out.

Cheers
Chris Coleman
Hexnode UEM

Marked SolutionPending Review
Participant
3 years ago
Marked SolutionPending Review

U r right. I added Write-Host and I can see the output of the ps1 script. I added the command @echo off in the batch file and now I am not able to see show output option. Now how do I display something using the batch script?

Marked SolutionPending Review
Hexnode Expert
3 years ago
Marked SolutionPending Review

Glad things worked out with the PowerShell script. You need to add an echo command to print something using batch script. For instance, if you want to print “Success” add the command,

Cheers!!
Chris Coleman
Hexnode UEM