CmdID / PowerShell / Cmdlets / Wait
Wait-Process
Waits for the processes to be stopped before accepting more input. PowerShell reference
From the PowerShell reference 4 parameters
What it does
Waits for the processes to be stopped before accepting more input. The Wait-Process cmdlet waits for one or more running processes to be stopped before accepting input. In the PowerShell console, this cmdlet suppresses the command prompt until the processes are stopped. You can specify a process by process name or process ID (PID), or pipe a process object to Wait-Process. Wait-Process works only on processes running on the local computer.
Wait-Process [-Name] <String[]> [[-Timeout] <Int32>] [<CommonParameters>]Wait-Process [-Id] <Int32[]> [[-Timeout] <Int32>] [<CommonParameters>]Wait-Process [[-Timeout] <Int32>] -InputObject <Process[]> [<CommonParameters>]
Stop a process and wait
PS C:> $nid = (Get-Process notepad).Id
PS C:> Stop-Process -Id $nid
PS C:> Wait-Process -Id $nidIdentifySpecifying a process
PS C:> $p = Get-Process notepad
PS C:> Wait-Process -Id $p.Id
PS C:> Wait-Process -Name "notepad"
PS C:> Wait-Process -InputObject $pIdentifyWait for processes for a specified time
PS C:> Wait-Process -Name outlook, winword -Timeout 30IdentifyIts page in the reference: Wait-Process.
Parameters
-IdSpecifies the process IDs of the processes. To specify multiple IDs, use commas to separate the IDs. To find the PID of a process, type Get-Process.-InputObjectSpecifies the processes by submitting process objects. Enter a variable that contains the process objects, or type a command or expression that gets the process objects, such as the Get-Process cmdlet.-NameSpecifies the process names of the processes. To specify multiple names, use commas to separate the names. Wildcard characters are not supported.-TimeoutSpecifies the maximum time, in seconds, that this cmdlet waits for the specified processes to stop. When this interval expires, the command displays a non-terminating error that lists the processes that are still running, and ends the wait. By default, there is no time-out.