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

> this looks like there are other options to catch RemoteException from within PS

see http://stackoverflow.com/questions/17548621/how-to-catch-external-command-failure

for a generic way to catch $lastexitcode

function Exec { [CmdletBinding()] param( [Parameter(Position=0,Mandatory=1)][scriptblock]$cmd, [Parameter(Position=1,Mandatory=0)][string]$errorMessage = ($m +sgs.error_bad_command -f $cmd) ) & $cmd if ($lastexitcode -ne 0) { throw ("Exec: " + $errorMessage) } }

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

  • Comment on Re^2: Need Help: Error/die-Handling with Perl & Powershell ($lastexitcode)
  • Download Code