Contact Info

Crumbtrail » Administration » Powershell » Powershell 3.0 » Wait-Job

Wait-Job - Powershell 3.0 CmdLet

ActiveXperts Network Monitor ships with integrated Powershell scripts to monitor complex network. The scripts run out of the box
Download the ActiveXperts Network Monitor FREE version now »


Short description
Suppresses the command prompt until one or all of the Windows PowerShell background jobs running in the session are complete.

Wait-Job [-Id] <Int32[]> [-Any] [-Force] [-Timeout <Int32>] [<CommonParameters>]
Wait-Job [-Filter] <Hashtable> [-Any] [-Force] [-Timeout <Int32>] [<CommonParameters>]
Wait-Job [-InstanceId] <Guid[]> [-Any] [-Force] [-Timeout <Int32>] [<CommonParameters>]
Wait-Job [-Job] <Job[]> [-Any] [-Force] [-Timeout <Int32>] [<CommonParameters>]
Wait-Job [-Name] <String[]> [-Any] [-Force] [-Timeout <Int32>] [<CommonParameters>]
Wait-Job [-State] <JobState> [-Any] [-Force] [-Timeout <Int32>] [<CommonParameters>]

The Wait-Job cmdlet waits for Windows PowerShell background jobs to complete before it displays the command prompt. You
 can wait until any background job is complete, or until all background jobs are complete, and you can set a maximum wa
it time for the job.

When the commands in the job are complete, Wait-Job displays the command prompt and returns a job object so that you ca
n pipe it to another command.

You can use Wait-Job cmdlet to wait for background jobs, such as those that were started by using the Start-Job cmdlet 
or the AsJob parameter of the Invoke-Command cmdlet. For more information about Windows PowerShell background jobs, see

Beginning in Windows PowerShell 3.0, the Wait-Job cmdlet also waits for custom job types, such as workflow jobs and ins
tances of scheduled jobs. To enable Wait-Job to wait for jobs of a particular type, import the module that supports the
 custom job type into the session before running a Get-Job command, either by using the Import-Module cmdlet or by usin
g or getting a cmdlet in the module. For information about a particular custom job type, see the documentation of the c
ustom job type feature.