I agree with marto, not enough details

Probably just catching stdout/stderr is needed?

see http://stackoverflow.com/questions/8184827/powershell-capture-the-output-from-external-process-that-writes-to-stderr-in-a

alternatively try to see if die() raises an exception ...

see http://stackoverflow.com/questions/20637600/catch-perl-errors-from-powershell-script

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

PS: FWIW, found the links by googling your title!

update

tested, you need to catch STDERR

PS C:\Windows\system32> $cmdOutput = perl -e 'die(1)' 2>&1 PS C:\Windows\system32> echo $cmdOutput perl.exe : 1 at -e line 1. Bei Zeile:1 Zeichen:18 + $cmdOutput = perl <<<< -e 'die(1)' 2>&1 + CategoryInfo : NotSpecified: (1 at -e line 1.:String) [ +], Remot eException + FullyQualifiedErrorId : NativeCommandError

this looks like there are other options to catch RemoteException from within PS, but unfortunately that's OT and not my expertise.

FWIW: I tested a PS try but it didn't catch.


In reply to Re: Need Help: Error/die-Handling with Perl & Powershell (updated) by LanX
in thread Need Help: Error/die-Handling with Perl & Powershell by PSPler

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.