First, let me explain the scenario: we often have to clone VMs in Hyper-V, which means we need to run sysyprep.exe on the VM we want to clone, copy the associated VHD file, and then create a new VM with the copied VHD file.
The problem comes when we want to automate this with PowerShell, and we’re unable to join the systems to the domain automatically (both the original and the clone). If we were running Server 2016 on all of our hypervisors, this would be no problem considering we could connect in through Hyper-V’s cmdlets. Alas, we’re running Server 2012 R2 with no plan to upgrade for some years.
My line of thinking is that if the original has the FOG client installed, I’d just need PowerShell to edit the MYSQL database on the FOG server to create a new record with the associated image, group, etc (the key thing being the MAC address and having it set to join the domain automatically).
So, a few questions:
- Is this the way to go about doing this, or is there a better method?
- Is this possible with FOG?
- If it is possible with FOG, what’s the recommended method of creating a new record? Is it to directly edit the MYSQL database? Or would I be able to connect through an API?
I’d be interested to know if anyone else has had a similar issue and how they’ve worked around it.
I did wonder whether it was worth uploading the image of the clone and then redeploying it, but that would take far too long.
Any help as usual would be greatly appreciated!