When running the batch file remotely using WinRM,
psexec -i "$session_id" -d "C:\test.bat"
Why are you using Sysinternal's psexe?
-d Don't wait for process to terminate (non-interactive).
-i Run the program so that it interacts with the desktop of the
specified session on the remote system. If no session is
specified the process runs in the console session.
The -d switch says to launch the process and then terminate. So yes, you won't get any output. I would expect you would also need to pass the -accepteula switch, otherwise it might hang.
Your image shows "C:\Test.exe". Is that the root program that you are trying to execute? What are you trying to do with the session variable?
Why don't you take the commands that are in C:\Test.bat and just put them into your WinRM script? Replace the line that has whoami.exe with the path to your test.exe.
Like this.
$script =
{
"This script is running on {0}" -f $env:COMPUTERNAME
"Calling whoami to execute on the remote system"
c:\Windows\system32\whoami.exe
}
Invoke-Command -ComputerName "test10b" -ScriptBlock $script
Is test.exe a GUI or command line program? If you want to run it over a remote WinRM session, it has to be a command line program so that stdout and stderr can captured and sent back to the source machine.