It looks like you are running the MSI installer. When launched from the console, control returns immediately, and MSI creates a new process to launch the installer. Cannot change this behavior.
You may need to use Get-Process to find the process named msiexec and wait for it to complete. The msiexec process is always executed, which handles the launch of new installers, so you need to find the msiexec process that started after the installation began.
$msiexecd = Get-Process -Name 'msiexec' C:\Users\Admin\Documents\Setup-2.0.exe exe ` /s ` /v"EULAACCEPTED=\"Yes\" /l*vc:\install.log /qn" $myMsi = Get-Process -Name 'msiexec' | Where-Object { $_.Id -ne $msiexecd.Id } $myMsi.WaitForExit() Write-Verbose $myMsi.ExitCode
source share