Hi All,
Hopefully someone can help.
I have the below which seems to work fine (in order to run an installer both using credentials and elevated):
$credentials = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $credu, $credp $subproc = "Start-Process -FilePath msiexec.exe -ArgumentList '/i ', '\\networkloc\INSTALLER.msi', 'SERIALNUMBER=BLA DEFAULTSINI=\\networkloc\nsdefaults.ini ROAMINGUSERINI=\\networkloc\roamingdef.ini PRODUCTUPDATEFLAG=1 REBOOT=ReallySuppress REGION=UK'" $args = "-noprofile -command &{" + $subproc + " -verb runas -passthru}" $ProcID1 = Start-Process powershell -Credential ($credentials) -ArgumentList $args Write-Host("ProcID1: $ProcID1") Write-Host("ProcID2: $ProcID2") do {start-sleep -Milliseconds 500} until ($ProcID1.HasExited) do {start-sleep -Milliseconds 500} until ($ProcID2.HasExited) DO OTHER STUFF
The difficulty I have is that I need to get the PID of the nested running application in order to be able to wait for it to exit, so in this example the specific \networkloc\INSTALLER.msi PID
Please note that above script is a saved as a function so will be called multiple times as part of a bigger script and I just want it to wait until each one is done in turn.