<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">

  <!-- Template variables -->
  <ad:set name="architecture" value="amd64" /> <!-- "x86" for 32-bit OS editions and "amd64" for 64-bit OS editions -->

    <settings pass="generalize">
        <component name="Microsoft-Windows-ServerManager-SvrMgrNc" processorArchitecture="#architecture#" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <DoNotOpenServerManagerAtLogon>true</DoNotOpenServerManagerAtLogon>
        </component>
        <component name="Microsoft-Windows-OutOfBoxExperience" processorArchitecture="#architecture#" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <DoNotOpenInitialConfigurationTasksAtLogon>true</DoNotOpenInitialConfigurationTasksAtLogon>
        </component>
    </settings>
    <settings pass="specialize">
        <component name="Microsoft-Windows-IE-ESC" processorArchitecture="#architecture#" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <IEHardenAdmin>false</IEHardenAdmin>
            <IEHardenUser>false</IEHardenUser>
        </component>
        <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="#architecture#" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
			<ComputerName>#vm.Hostname.ToUpper()#</ComputerName>
			<RegisteredOwner>#user.FirstName# #user.LastName#</RegisteredOwner>
			<RegisteredOrganization>#user.CompanyName#</RegisteredOrganization>
            <TimeZone>W. Europe Standard Time</TimeZone>
            <ProductKey>Y4TGP-NPTV9-HTC2H-7MGQ3-DV4TW</ProductKey>
        </component>
        <component name="Microsoft-Windows-TCPIP" processorArchitecture="#architecture#" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <Interfaces>

			        <!-- External network -->
        <ad:if test="#isnotempty(external_nic.MacAddress)#">
          <Interface wcm:action="add">
            <Identifier>#external_nic.MacAddress#</Identifier>
            <Ipv4Settings>
              <DhcpEnabled>#external_nic.IsDHCP.ToString().ToLower()#</DhcpEnabled>
            </Ipv4Settings>
            <ad:if test="#not(external_nic.IsDHCP)#">
              <UnicastIpAddresses>
                <ad:foreach collection="#external_nic.IPAddresses#" var="ip" index="i">
                  <IpAddress wcm:action="add" wcm:keyValue="#i#">#ip.IPAddress#/#ip.SubnetMaskCidr#</IpAddress>
                </ad:foreach>
              </UnicastIpAddresses>
            </ad:if>
            <ad:if test="#isnotempty(external_nic.DefaultGateway)#">
              <Routes>
                <Route wcm:action="add">
                  <Identifier>0</Identifier>
                  <Prefix>0.0.0.0/0</Prefix>
                  <NextHopAddress>#external_nic.DefaultGateway#</NextHopAddress>
                  <Metric>20</Metric>
                </Route>
              </Routes>
            </ad:if>
          </Interface>
        </ad:if>

        <!-- Management network -->
        <ad:if test="#isnotempty(management_nic.MacAddress)#">
          <Interface wcm:action="add">
            <Identifier>#management_nic.MacAddress#</Identifier>
            <Ipv4Settings>
              <DhcpEnabled>#management_nic.IsDHCP.ToString().ToLower()#</DhcpEnabled>
            </Ipv4Settings>
            <ad:if test="#not(management_nic.IsDHCP)#">
              <UnicastIpAddresses>
                <ad:foreach collection="#management_nic.IPAddresses#" var="ip" index="i">
                  <IpAddress wcm:action="add" wcm:keyValue="#i#">#ip.IPAddress#/#ip.SubnetMaskCidr#</IpAddress>
                </ad:foreach>
              </UnicastIpAddresses>
            </ad:if>
            <ad:if test="#isnotempty(management_nic.DefaultGateway)#">
              <Routes>
                <Route wcm:action="add">
                  <Identifier>0</Identifier>
                  <Prefix>0.0.0.0/0</Prefix>
                  <NextHopAddress>#management_nic.DefaultGateway#</NextHopAddress>
                  <Metric>20</Metric>
                </Route>
              </Routes>
            </ad:if>
          </Interface>
        </ad:if>

        <!-- Private network -->
        <ad:if test="#isnotempty(private_nic.MacAddress)#">
          <Interface wcm:action="add">
            <Identifier>#private_nic.MacAddress#</Identifier>
            <Ipv4Settings>
              <DhcpEnabled>#private_nic.IsDHCP.ToString().ToLower()#</DhcpEnabled>
            </Ipv4Settings>
            <ad:if test="#not(private_nic.IsDHCP)#">
              <UnicastIpAddresses>
                <ad:foreach collection="#private_nic.IPAddresses#" var="ip" index="i">
                  <IpAddress wcm:action="add" wcm:keyValue="#i#">#ip.IPAddress#/#ip.SubnetMaskCidr#</IpAddress>
                </ad:foreach>
              </UnicastIpAddresses>
            </ad:if>
            <ad:if test="#isnotempty(private_nic.DefaultGateway)#">
              <Routes>
                <Route wcm:action="add">
                  <Identifier>0</Identifier>
                  <Prefix>0.0.0.0/0</Prefix>
                  <NextHopAddress>#private_nic.DefaultGateway#</NextHopAddress>
                  <Metric>20</Metric>
                </Route>
              </Routes>
            </ad:if>
          </Interface>
        </ad:if>

        </Interfaces>
        </component>
        <component name="Microsoft-Windows-DNS-Client" processorArchitecture="#architecture#" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <DNSDomain>#vm.Domain#</DNSDomain>
      <Interfaces>

        <!-- External network DNS settings -->
        <ad:if test="#isnotempty(external_nic.MacAddress) and (isnotempty(external_nic.PreferredNameServer) or isnotempty(external_nic.AlternateNameServer))#">
          <Interface wcm:action="add">
            <Identifier>#external_nic.MacAddress#</Identifier>
            <DNSServerSearchOrder>
              <ad:if test="#isnotempty(external_nic.PreferredNameServer)#">
                <IpAddress wcm:action="add" wcm:keyValue="1">#external_nic.PreferredNameServer#</IpAddress>
              </ad:if>
              <ad:if test="#isnotempty(external_nic.AlternateNameServer)#">
                <IpAddress wcm:action="add" wcm:keyValue="2">#external_nic.AlternateNameServer#</IpAddress>
              </ad:if>
            </DNSServerSearchOrder>
          </Interface>
        </ad:if>

        <!-- Management network DNS settings -->
        <ad:if test="#isnotempty(management_nic.MacAddress) and (isnotempty(management_nic.PreferredNameServer) or isnotempty(management_nic.AlternateNameServer))#">
          <Interface wcm:action="add">
            <Identifier>#management_nic.MacAddress#</Identifier>
            <DNSServerSearchOrder>
              <ad:if test="#isnotempty(management_nic.PreferredNameServer)#">
                <IpAddress wcm:action="add" wcm:keyValue="1">#management_nic.PreferredNameServer#</IpAddress>
              </ad:if>
              <ad:if test="#isnotempty(management_nic.AlternateNameServer)#">
                <IpAddress wcm:action="add" wcm:keyValue="2">#management_nic.AlternateNameServer#</IpAddress>
              </ad:if>
            </DNSServerSearchOrder>
          </Interface>
        </ad:if>

        <!-- Private network DNS settings -->
        <ad:if test="#isnotempty(private_nic.MacAddress) and (isnotempty(private_nic.PreferredNameServer) or isnotempty(private_nic.AlternateNameServer))#">
          <Interface wcm:action="add">
            <Identifier>#private_nic.MacAddress#</Identifier>
            <DNSServerSearchOrder>
              <ad:if test="#isnotempty(private_nic.PreferredNameServer)#">
                <IpAddress wcm:action="add" wcm:keyValue="1">#private_nic.PreferredNameServer#</IpAddress>
              </ad:if>
              <ad:if test="#isnotempty(private_nic.AlternateNameServer)#">
                <IpAddress wcm:action="add" wcm:keyValue="2">#private_nic.AlternateNameServer#</IpAddress>
              </ad:if>
            </DNSServerSearchOrder>
          </Interface>
        </ad:if>
      </Interfaces>			
	 </component>
	 <component name="Microsoft-Windows-TerminalServices-LocalSessionManager" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <fDenyTSConnections>false</fDenyTSConnections>
    </component>
    <component name="Networking-MPSSVC-Svc" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <FirewallGroups>
            <FirewallGroup wcm:action="add" wcm:keyValue="EnableRemoteDesktop">
                <Active>true</Active>
                <Group>Remote Desktop</Group>
                <Profile>all</Profile>
            </FirewallGroup>
			<FirewallGroup wcm:action="add" wcm:keyValue="EnableRemoteDesktopDE">
                <Active>true</Active>
                <Group>Remotedesktop</Group>
                <Profile>all</Profile>
            </FirewallGroup>
        </FirewallGroups>
    </component>
    </settings>
    <settings pass="oobeSystem">
        <component name="Microsoft-Windows-International-Core" processorArchitecture="#architecture#" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <InputLocale>en-US</InputLocale>
            <SystemLocale>en-US</SystemLocale>
            <UILanguage>en-US</UILanguage>
            <UserLocale>en-US</UserLocale>
        </component>
        <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="#architecture#" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <OOBE>
                <HideEULAPage>true</HideEULAPage>
                <ProtectYourPC>1</ProtectYourPC>
                <NetworkLocation>Work</NetworkLocation>
            </OOBE>
            <UserAccounts>
				<!-- Administrator account password -->
				<AdministratorPassword>
					<Value>#vm.AdministratorPassword#</Value>
					<PlainText>true</PlainText>
                </AdministratorPassword>
            </UserAccounts>
        </component>
    </settings>
</unattend>