LastExitCode Not Working When Calling An External .exe


hello,

i'm new powershell, wrote powershell 2.0 script attempting load edi document converted a flat file infor's visual erp using vmdixchg module.  script working great, until tried add in error handling.  $lastexitcode returned on successful execution 2147483647 max integer value, doesn't seem valid code.  i've tried checking $? -eq $false no luck because returns false, regardless of whether execution was successful.  idea why neither of these checks working?

# call vmdixchg import order visual if cpo0001 exists
    & \\path\vmdixchg.exe -d database -u user -p password -f f:\edi\editovisual\ cpo0001 | out-null
    # send email if vmdixchg encountered issues
    if ($lastexitcode -ne 0)
    {
        $smtpserver = "smtpserver"
        $emailfrom = "email@domain.com"
        $emailto = "email@domain.com"
        $emailsubject = "edi error"
        $emailmessage = "an error received loading cpo001 visual.  translation log attached."
        $emailattachment = "f:\edi\editovisual\cpo0001.xml"
        send-mailmessage -smtpserver $smtpserver -from $emailfrom -to $emailto -subject $emailsubject -body $emailmessage -attachments $emailattachment
    }

in advance.

hmm, adding parentheses around parameters seems cause vmdixchg.exe think it's 1 large parameter , error out.  attempted run vmdixchg directly command line , errorlevel = 2147483647, problem must not powershell related.  contact visual see how reccomend checking errors.

thanks help.



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Error: 0x80073701 when trying to add Print Services Role in Windows 2012 Standard

difference between wuauclt1.exe and wuauclt.exe

Windows 2016 RDS event 1306 Connection Broker Client failed to redirect the user... Error: NULL