Pass | Component | The effect of this component |
Generalize | Microsoft-Windows-Shell-Setup | Specifies that Sysprep should not remove any icons from the Quick Launch toolbar |
Specialize | Microsoft-Windows-UnattendedJoin | Specifies the domain to join and credentials needed to join or whether to just ‘join’ a named workgroup |
Microsoft-Windows-Shell-Setup | Specifies Computer name, registered organsiation and owner, and time zone | |
Microsoft-Windows-IE-InternetExplorer | Sets home page to blank and whether to disable the run-once wizard | |
Microsoft-Windows-Deployment | Enables local administrator account | |
Microsoft-Windows-International-Core | Specifies Input Locale, System Locale, UI Language and UserLocale. The input locale sets an initial keyboard layout. | |
Microsoft-Windows-TapiSetup | Tapi settings | |
Microsoft-Windows-IE-ESC | Turns off the IE security settings | |
Microsoft-Windows-TerminalServices-LocalSessionManager | Enables Terminal services connection to the VM | |
Networking-MPSSVC-Svc | Turns the firewall off on the VM | |
Microsoft-Windows-TCPIP | Sets TCP/IP settings, including IP address, subnet mask and default gateway | |
Microsoft-Windows-DNS-Client | Specifies the DNS Server IP address | |
OobeSystem | Microsoft-Windows-Shell-Setup | Specifies local administrator password, whether to hide the EULA pages plus sets the time zone |
Microsoft-Windows-International-Core | Specifies a 2nd language to be setup for this VM |
- Creating a differencing disk – this is the ‘difference’ between a reference or parent Vhdx and the disk.
- Creating a VM in Hyper-V.
- Adding the differencing disk into the VM.
- Mounting the VHD on the host computer.
- Based on a pre-built Unattend.XML, creating a customised Unattend.XML file and saving it to the on the mounted VHDX.
- Dismounting the VHDX from the host
- Setting VM settings including memory, startup actions etc.
- Starting the VM.
Once the VM has started, windows setup proceeds to install Windows as per the Unattend.XML file. The creation of the VM itself takes just 20-30 seconds, followed by the actual installation which takes 10-15 more minutes (and more if you are doing multiple installations in parallel).
The Created VM
The VM created by the Create-VM function will either be a workgroup VM or a VM that has been joined to the domain, as specified in the Unattend.XML file. This VM will be fairly vanilla with only a few options specified (as noted above). There are no extra applications loaded, and the Unattend.dj.xml file only ‘works’ once you have the DC up and running.
The Create-VM script takes around 27-30 seconds to create and start the VM in Hyper-V. On my WIn8 laptop, it take a further 5 minutes to complete the creating of the first DC.
Example
Once you have the reference disk, you can call the Build-VM function like this:
$ref = … # Path to the reference disk
$Path = … # Path to where to put the VM and differencing disk
$unadj = … # Path to Unattend.XML
# Now Create the VM
Create-VM -Name "Srv1" -VmPath $Path –ReferenceVHD $Ref -Network "Internal" `
-UnattendXML $unadj -Verbose -IPAddr '10.0.0.30/24' `
-DNSSvr 10.0.0.10 -VMMemory 512mb
You run this script ON the Hyper-V server. Once the Create-VM function completes, which takes between 20-25 seconds in my case, Hyper-V starts up the VM and completes the installation of the OS inside the VM. The complete installation takes 20 minutes or so (depending on your system, how much RAM you give the VM, the speed of your system, etc.). Once the setup is complete, you can move on and configure the VM with application and application settings.
Where are we on this journey?
In the these first three blog posts, I’ve set out the objectives of a VM Build module for building VMs and the two core functions/scripts. The two scripts create a base VM disk, a differencing disk and a VM. Each VM is customised a little in the call to Create-VM – in effect creating a base VM. Once this VM has been created, you can then load additional applications and Windows features (e.g. making the DC a certificate authority). In the next episodes of this set of blog articles, I’ll start looking at the scripts that add those applications and features. And I’ll share the interesting things I’ve discovered along the way. I’ll also publish the scripts and the unattended XML files.
3 comments:
after created the vm, failed to set the ip as expected.
That suggests that the editing of the XML file did not work - check file permissions and that all the files are in the right place. Run the script in debug mode, line at a time. THese scripts run perfectly as long as everything is in the right places!
I found the reason. Eithernet, this parameter caused the issue. added the following code:
#changed the VM's mac
Get-VM -Name $Name | Get-VMNetworkAdapter | Set-VMNetworkAdapter -StaticMacAddress $mac
#change VM's identifier as max with Hex format
$tcpip = $xml.unattend.settings.component | Where-Object { $_.Name -eq "Microsoft-Windows-TCPIP" }
$tcpip.Interfaces.Interface.Identifier = $macWithDash
$tcpip.Interfaces.Interface.UnicastIpAddresses.IpAddress.InnerText=$IPAddr
with changed above, it works.
Post a Comment