start sleep powershell code example
Example 1: pause powershell script until keypress
Write-Host -NoNewLine 'Press any key to continue...';
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
Example 2: powershell start a process and wait for it to finish
$proc = Start-Process -Wait -FilePath $procPath -ArgumentList $argument
do{sleep 1}while(Get-Process -Name $procName -ErrorAction SilentlyContinue)