VMware Cloud Community
JamesBrownlie
Contributor
Contributor

Multithreading scripts in powershell

Hi Everyone,

Ive had a bit of a search around, even on the microsoft website for powershell and there is only open ended questions about this topic in there. Hoping that someone here might know what is going on so i can finish my script.

Is it possible to multithread in the tradional sense in powershell? if so, how do i do it? if not, is there a way around it.

Example.

I am looking at running multiple new-vm cmdlets using the -runasync switch and want to use the wait-task cmdlet after each one of them has finished.

Thanks,

James.

Tags (2)
0 Kudos
3 Replies
marco_shaw
Enthusiast
Enthusiast

I'm going to assume you're wanting to do this with PowerShell v1. Check this:

0 Kudos
RyanWitschger
Contributor
Contributor

I have a blog article showing you how to do this in V2:

ryan.witschger.net/?p=22

And another showing how to get progress back from your threads:

http://ryan.witschger.net/?p=132

0 Kudos
bulletprooffool
Champion
Champion

Nice Ryan!

One day I will virtualise myself . . .
0 Kudos