Powershell scripts do not show output

ybeees
expand collapsive

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.

All Replies

  • Chris Coleman

    Chris Coleman

    Hexnode

    Chris Coleman

    Moderator

    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

  • ybeees

    ybeees

    Participant

    ybeees

    Participant

    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?

  • Chris Coleman

    Chris Coleman

    Hexnode

    Chris Coleman

    Moderator

    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,

    echo Success

    Cheers!!
    Chris Coleman
    Hexnode UEM