Example on how to wait for a window to appear for an executable initiated from PowerShell
$regeditInstance = [Diagnostics.Process]::Start("regedit","-m")
#wait the regedit window to appear
while ($regeditInstance.MainWindowHandle -eq 0){
sleep -Milliseconds 100
}