PowerShell is King – Building a Reference Image Factory (v 3.2)
Posted by Mikael Nystrom on February 23, 2017
The Image Factory has been re-worked and updated. It also has moved to GitHub https://github.com/DeploymentBunny/ImageFactoryV3ForHyper-V/
Concept and flow
The idea is the same, we use MDT, create refimages task sequences that runs without any questions. A PowerShell script will grab all enabled Task Sequences in a specified folder, create a VM for each of them. Grab the Bios Serial number from each om them, update customsettings ini with that information, start the VM’s (number of concurrent VM’s determine how many VM’s can run at the same time, wait until all VM’s are done and finally removes all VM’s for a cleanup process. You can run the script as is (if you store it in C:\Setup\ImageFactoryV3ForHyper-V on you MDT server), or you can open it in ISE and run section by section to see what happens.
The XML file (C:\Setup\ImageFactoryV3ForHyper-V\ImageFactoryV3.xml)
Is a control file for settings, pretty straightforward, just make sure that all values are correct.
The Script C:\Setup\ImageFactoryV3ForHyper-V\ImageFactoryV3-Build.ps1
The script contains some functions and logic, each section is described so you do know what it does. There are switches to the script,
UppdateBoot image $True, updates the bootimage before copy, EnableMDTMonitoring require that MDT monitoring is enabled of the deployment share and testmode is not yet working (I’ll get back on that)
The PSINI Module
One big change is that instead of using a hack, using KVP i switches over to use a module called PSINI, it basically turns customsettings.ini into a hash table, making it easy to configure using PowerShell. That also means you need to download that module from TechNet Gallery http://gallery.technet.microsoft.com/scriptcenter/ea40c1ef-c856-434b-b8fb-ebd7a76e8d91and all credit for that module goes to http://oliver.lipkau.net/blog