PowerShell Logo Small

Wait-Process



This is the built-in help made by Microsoft for the command 'Wait-Process', in PowerShell version 5 - as retrieved from Windows version 'Microsoft Windows Server 2012 R2 Standard' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Waits for the processes to be stopped before accepting more input.

SYNTAX


Wait-Process [-Name] <String[]> [[-Timeout] [<Int32>]] [-InformationAction {SilentlyContinue | Stop | Continue | Inquire | Ignore | Suspend}] [-InformationVariable
[<System.String]>]] [<CommonParameters>]
Wait-Process [-Id] <Int32[]> [[-Timeout] [<Int32>]] [-InformationAction {SilentlyContinue | Stop | Continue | Inquire | Ignore | Suspend}] [-InformationVariable
[<System.String]>]] [<CommonParameters>]
Wait-Process [[-Timeout] [<Int32>]] [-InformationAction {SilentlyContinue | Stop | Continue | Inquire | Ignore | Suspend}] [-InformationVariable [<System.String]>]]
-InputObject <Process[]> [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The Wait-Process cmdlet waits for one or more running processes to be stopped before accepting input. In the Windows 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.



<

RELATED LINKS

Online Version: http://go.microsoft.com/fwlink/p/?linkid=293930
Debug-Process
Get-Process
Start-Process
Stop-Process
Wait-Process

REMARKS

<

Examples


-------------------------- EXAMPLE 1 --------------------------

PS C:\>$nid = (get-process notepad).id
PS C:\>stop-process -id $nid
PS C:\>wait-process -id $nid



These commands stop the Notepad process and then wait for the process to be stopped before proceeding with the next command.

The first command uses the Get-Process cmdlet to get the ID of the Notepad process. It saves it in the $nid variable.

The second command uses the Stop-Process cmdlet to stop the process with the ID saved in $nid.

The third command uses the Wait-Process cmdlet to wait until the Notepad process is stopped. It uses the ID parameter of Wait-Process to identify the process.










-------------------------- EXAMPLE 2 --------------------------

PS C:\>$p = get-process notepad
PS C:\>wait-process -id $p.id
PS C:\>wait-process -name notepad
PS C:\>wait-process -inputobject $p



These commands show three different methods of specifying a process to the Wait-Process cmdlet. The first command gets the Notepad process and saves it in the $p variable.

The second command uses the ID parameter, the third command uses the Name parameter, and the fourth command uses the InputObject parameter.

These commands have the same results and can be used interchangeably.










-------------------------- EXAMPLE 3 --------------------------

PS C:\>wait-process -name outlook, winword -timeout 30



This command waits 30 seconds for the Outlook and Winword processes to stop. If both processes are not stopped, the cmdlet displays a non-terminating error and the command
prompt.