Multiple script execution

So, I had a scenario the other day where I wanted to run a PowerShell script on approximately 300 remote computers in an outage windows of no more than 30 minutes. The challenge was the script took 2 minutes to complete. I didn’t have enough fingers and toes for the math, so used a calculator to determine it would be… 600 minutes. Hmm, last time I checked 600 minutes is more than 30. So what to do..

The only way I could see this getting across the line was doing things in parallel. At 2 minutes per computer, I would need… give me a second… 20! batches of 15 computers. That would allow me to knock it out in 30 minutes. Well that was great, how was I going to do that? Also, with all things I do, I wanted to make the script reusable.

Now there are numerous ways to attack this, PowerShell workflows or jobs for example, but I also wanted to see output on screen as it was running. So I needed to launch separate PowerShell consoles for each of my batches of scripts. Without further ado here is what was cobbled together:

Enjoy, pretty hacky, but that’s the way i roll!