I'm trying to execute a simple command using winrs and get the exit code back. If it's powershell, it's $LastExitCode and if it's CMD it's %errorleverl%
However, in my specific case, I'm running
winrs -r:remote_server -u:Remote_server/Administrator -p:password net localgroup Administrators
The object succeeds even though the command itself is not performed. It seems that the command executes a few seconds before the WinRM listener is up. (the server comes up after sysprep).
So... My question is: how can I get an indication about the actual command result.
I've tried the powershell IP (1.1) but couldn't get the exit code properly.