currently I'm developing a c# web service which is a "man in the middle". The Client can call a method "executeScript(String script)" and my web services invokes the script.
Currently the web service doesn't know which scripts the client will execute (normally exchange scripts). How I read the output correctly? e.g. Get Process or something else.
My Error Reading works allready. Example Script: "Get-Mailbox xxxxx"
if (pl.Error.Count > 0)
{
//error in pipeline
var errorList = pl.Error.Read() as Collection<ErrorRecord>;
if (errorList != null)
{
foreach (ErrorRecord er in errorList)
{
logger.Error(er.Exception.Message);
ExceptionObject eo = new ExceptionObject();
eo.message = er.Exception.Message;
eo.source = er.Exception.Source;
eo.stackTrace = er.Exception.StackTrace;
errors.Add(eo);
}
}
if (pso != null)
{
foreach (PSObject o in pso)
{
logger.Info("size: " + o.Properties.Count());
logger.Info(o.ToString());
foreach (PSPropertyInfo psprop in o.Properties)
{
sb.AppendLine("Name: " + psprop.Name + ", Value: " + psprop.Value + ", MemberType: " + psprop.MemberType);
}
}
logger.Info(pso.ToString());
pro.result = sb.ToString();
}
logger.Info(o.ToString()); -> Get-Mailbox xxxxx
The propeties: "Name: Length, Value: 19, MemberType: Property"
Thats not the correct output. Is there a way, to get the response as string as it is in the orginal powershell console? (Dynamically on every script!)