I have a script that is working great, but I would like the addition of retrieving exit codes. My script uninstalls one program and installs another using the Start-Process cmdlet, but the exit code is not displaying. I read that there is a bug in the Start-Process cmdlet and that is why it is not displaying an exit code.
Basically all I am doing is the following:
$p=start-process -filepath msiexec -argumentlist ‘parameter1’, ‘parameter2’, ‘parameter3’ -nonewwindow -wait
if ($p.exitcode -eq 0)
write-output “the program was installed successfully”
I used the following method as well, but it is still not displaying the exit code:
$p = [System.Diagnostics.Process]::Start(“program.exe”, “parameter1”)
Does anyone have any good techniques for grabbing exit codes?