$app = Start-Process notepad -passthru Wait-Process $app.Id
Here is what the above code is Doing:
1. Start-Process is used to start a process.
2. The -passthru parameter is used to return a process object.
3. Wait-Process is used to wait for a process to complete.
4. The process object is passed to Wait-Process.
5. The process object’s Id property is used to identify the process.