Recently when working on our deployment of machines, we hit a few brick walls.
The main issue was how long it takes for a template from vSphere to be cloned, then join a domain. The delay is whilst you wait for the machine to Sysprep and VMWare to do its magic.
At first, I was dirty and put a delay in our creation scripts before doing anything else to the machine, but this just didn’t cut it.
So, I moved on to pre-staging the VM in our Windows AD, which meant things such as Group Policies and Security Groups would be applied on its very first boot which meant one less reboot before our virtual machines were ready to have applications deployed to them.
Here’s the function which can perform said wizardry… it’s pretty simple but doesn’t seem to be very well documented anyplace.