powershell - C++-CLI Pipeline only returns the first row of the error message -


i'm executing exchange powershell commands through pipeline code.

the problem when command executed on powershell directly error returned 4 rows long, when run command through pipeline returns first row of error message.

this code have far:

bool ps_calls::check_invoke(pipeline^ pipeline) {     if (pipeline->error->count <= 0)         return true;      collection<system::object^> errorcollection =  pipeline->error->readtoend();     (int i=0; i< errorcollection.count; i++)     {         string^ msg = string::format("error {0}",errorcollection[i]->tostring());         m_errors->add(msg);         m_logger->info_msg(string::format("error: {0}", msg));     }      return false; } 

this example of pipeline returns now:

error: error operation couldn't performed because object 'testing' couldn't found on 'server'. 

this example of error message if same command executed on powershell console manually:

the operation couldn't performed because object 'test' couldn't found on 'server'.      + categoryinfo          : notspecified: (:) [get-mailboxdatabase], managementobjectnotfoundexception      + fullyqualifiederrorid : 2f753561,microsoft.exchange.management.systemconfigurationtasks.getmailboxdatabase      + pscomputername        : server 

i able rest of error message can see errorid when error occurs.

powershell doesn't call tostring when formatting, that's why don't see same output.

some host applications typically pipe output out-default - if did that, you'd see expected format errors.

other host applications pipe output out-string - format objects in same way formatted if piped out-default, you'll string object can log need to.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -