VMware Cloud Community
JiriNedved
Contributor
Contributor
Jump to solution

Parallel uploads to different ESXi servers

Hi guys,

I am trying to execute several simultaneous uploads to different ESXi servers.

I follow KB 2001041.

I am using Start-Job cmdlet with ScriptBlocks.

The output of the Get-Job cmdlet says, that those jobs are running sequentially. The next job starts after the previous has ended.

Please, could you give me an advice, how to run this kind of jobs simultaneously?

Thank you

1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

No problem :smileygrin:

After a quick look at your code, the reason why your background run in sequence, is due to the Wait-Job you have.

You can submit all Jobs and then move the Wait-Job outside of the foreach loop.

Your last lines could look like this

    Start-Job -ScriptBlock $ScriptBlock -ArgumentList $IPAddress, $ESXiCredential, $PSDriveName, $WorkingDirectory, $EntirePathToLogFile, $FileToBeUploaded, $EntirePathToFileToBeUploaded

}

Get-Job | Wait-Job


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

4 Replies
LucD
Leadership
Leadership
Jump to solution

It would help if you could show us your code.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
JiriNedved
Contributor
Contributor
Jump to solution

Hi LucD,

I attach my code:

- comments are in still in Czech, it is in the development stage

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

No problem :smileygrin:

After a quick look at your code, the reason why your background run in sequence, is due to the Wait-Job you have.

You can submit all Jobs and then move the Wait-Job outside of the foreach loop.

Your last lines could look like this

    Start-Job -ScriptBlock $ScriptBlock -ArgumentList $IPAddress, $ESXiCredential, $PSDriveName, $WorkingDirectory, $EntirePathToLogFile, $FileToBeUploaded, $EntirePathToFileToBeUploaded

}

Get-Job | Wait-Job


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

JiriNedved
Contributor
Contributor
Jump to solution

Thank you very much.

Your idea is correct.

Best regards

Jiří

Reply
0 Kudos