In the past, I've done the opposite, where I wanted to wait until a certain process starts in order to continue, and I've used WMI events to do it. It's worth a shot to see if the same technique helps you:
# Start a process to track
Start-Process "Notepad.exe"
# Get WMI to track process exits
Register-WmiEvent -Query "SELECT * FROM __instancedeletionevent WITHIN 5 WHERE targetinstance isa 'win32_process'" `
-SourceIdentifier "WMI.ProcessDeleted" `
-Action {
if($eventArgs.NewEvent.TargetInstance.Name -eq "Notepad.exe")
{
Write-Host "Notepad exited!"
# Raise an event to notify completion
New-Event "PowerShell.ProcessDeleted" -Sender $sender -EventArguments $EventArgs.NewEvent.TargetInstance | Out-Null
}
} | Out-Null
# Wait for the event signifying that we completed the work (timeout after 10 min)
Wait-Event -SourceIdentifier "PowerShell.ProcessDeleted" -Timeout 600 | Out-Null
# Remove any events we created
Get-Event -SourceIdentifier "PowerShell.ProcessDeleted" -ErrorAction SilentlyContinue | Remove-Event
# Unregister the event monitor
Unregister-Event -Force -SourceIdentifier "WMI.ProcessDeleted"
Just replace "Notepad.exe" with the name of your installer process, and remove the call to Write-Host (or replace with something more useful). If you close Notepad within 10 minutes (adjust to suit) you should see a message, otherwise we continue anyway so the script doesn't hang indefinitely.