Product, version and build: PowerShell Studio 2019, version 5.6.159
32 or 64 bit version of product: 64 bit
Operating system: Windows 10
32 or 64 bit OS: 64 bit
I'm using the Button - Start Job control and have some jobs that need to wait until another job completes. For example, the first job creates accounts in a remote system and the account creation/replication needs to be confirmed before the next jobs can run. Is there an equivalent of Get-Job | Wait-Job in this control?
Thanks!
Waiting for job to complete before starting another job when using the Start Job control
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
-
- Posts: 7
- Last visit: Wed Apr 20, 2022 6:20 am
Re: Waiting for job to complete before starting another job when using the Start Job control
You should use one job that does all of this. There is no mechanism for waiting other than the "Completed" script. You could use the completed script to start the next job but that doesn't really make much design sense.
Re: Waiting for job to complete before starting another job when using the Start Job control
Here are two methods that avoid waiting for replication to complete.
Code: Select all
# method #1
$domainController = Get-ADDomainController -Discover -Service PrimaryDC
New-ADUser .... -Server $domainController
Set-ADUser .... -Server $domainController
# method #2
$account = New-ADUser .... -PassThru
$account | Set-ADUser ....
-
- Posts: 7
- Last visit: Wed Apr 20, 2022 6:20 am
Re: Waiting for job to complete before starting another job when using the Start Job control
Thanks for the reply jvierra. A single job doesn't work for me. I have several jobs in my original PS script that connect to multiple remote PS sessions and having them run serially wouldn't provide any benefit time-wise.
Using the "Completed script" option sounds like the way I'll want to go.
Using the "Completed script" option sounds like the way I'll want to go.