While you used the "-Wait" switch you haven't used the "-Passthru" switch and you haven't kept the process object returned by the Start-Process cmdlet. See this link: obtaining-exitcode-using-start-process-and-waitforexit-instead-of-wait
When the process ends, check the "ExitCode" property of the process object.