Skip to content

Error handling #336

Open
Open
@mato

Description

This may not be a bug, I'm not a Powershell expert, but I don't know where else to ask:

Is there a way to reliably ensure that I get a clear indication on the Ruby side, when the Powershell command invoked by execute() results in an error or exception?

Trivial example:

irb(main):031:0> pwsh.execute('errorerrorerror')
=> 
{:exitcode=>0,
 :errormessage=>nil,
 :stderr=>[],
 :stdout=>
  "errorerrorerror: The term 'errorerrorerror' is not recognized as a name of a cmdlet, function, script file, or executable program.\nCheck the spelling of the name, or if a path was included, verify that the path is correct and try again.\n",
 :native_stdout=>nil}

I'd expect to get at least an :exitcode of 1, or any of :errormessage, :stderr populated. Instead, I get nothing, and the error text just shows up in :stdout.

If type errorerrorerror into an interactive pwsh session on Linux, then the error message is in red, so I'm assuming that Powershell "knows" it's an error?

Context: I'm trying to automate a bunch of Exchange maintenance using the EXOv3 Powershell module, but driving "what needs to be done" from a Ruby script, which connects to a bunch of other systems. If I get my EXOv3 invocations wrong, I get no indication on the Ruby side that the command(s) failed.

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    • Status

      Has been Actioned

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions