This project is read-only.

Last Exit Code from .Net object

Sep 4, 2012 at 5:49 PM

Hi guys,

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 account_to_add /ADD

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.

Any ideas?