I had the need to execute a MSI and get the script to return the exit code for a MSI installation. This is the script that I came up with.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
try { $filePath = ".\Adobe Flash Player (IE) 10.3.msi" $processSInput = New-Object System.Diagnostics.processSInput $processSInput.FileName = "$FilePath" $processSInput.Arguments = "/qn" $process = [System.Diagnostics.Process]::Start($processSInput) #$process.ProcessName $process.WaitForExit() $exitCode = $process.ExitCode Write-Host "Exit Code: $exitCode" } catch { Write-Host "Something went wrong" } |
No comments yet.