PowerShell 2.0: One Cmdlet at a Time 20 Wait-Job
Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Wait-Job cmdlet.
What can I do with it?
Wait for a background job to complete in the current session before returning the prompt to the user.
Example:
Wait for jobs 37,39 and 41 to finish, but use the Any parameter to only wait for the first one. You can see when first initiated the cursor does not return to the prompt.
As soon as one of those jobs completes the cursor returns the prompt. We then use the Get-Job cmdlet to confirm that even though Job 41 is still running we have been given the prompt back.
How could I have done this in PowerShell 1.0?
The concept of jobs did not exist in PowerShell 1.0. Waiting for a command to complete before having the prompt returned to the user was standard behaviour.