forked from cloudbase/windows-imaging-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Unattend.xslt
107 lines (95 loc) · 4.38 KB
/
Unattend.xslt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<xsl:stylesheet version="1.0"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
xmlns:u="urn:schemas-microsoft-com:unattend">
<xsl:output method="xml" indent="yes" />
<xsl:strip-space elements="*"/>
<xsl:param name="productKey" />
<xsl:param name="processorArchitecture" />
<xsl:param name="imageName" />
<xsl:param name="versionMajor" />
<xsl:param name="versionMinor" />
<xsl:param name="installationType" />
<xsl:param name="administratorPassword" />
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match='u:unattend/u:settings/u:component[@name="Microsoft-Windows-Setup"]/u:ImageInstall/u:OSImage/u:InstallFrom/u:MetaData/u:Value'>
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:value-of select="$imageName"/>
</xsl:copy>
</xsl:template>
<xsl:template match='u:unattend/u:settings/u:component[@name="Microsoft-Windows-Shell-Setup"]/u:OOBE/u:HideOnlineAccountScreens | u:unattend/u:settings/u:component[@name="Microsoft-Windows-Shell-Setup"]/u:OOBE/u:HideLocalAccountScreen'>
<xsl:if test="$versionMajor >= 6 and $versionMinor >= 2">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:if>
</xsl:template>
<xsl:template match='u:unattend/u:settings/u:component[@name="Microsoft-Windows-Shell-Setup"]/u:UserAccounts/u:AdministratorPassword|u:unattend/u:settings/u:component[@name="Microsoft-Windows-Shell-Setup"]/u:AutoLogon/u:Password'>
<xsl:copy>
<xsl:element name="Value" namespace="{namespace-uri()}">
<xsl:value-of select="$administratorPassword"/>
</xsl:element>
<xsl:element name="PlainText" namespace="{namespace-uri()}">true</xsl:element>
</xsl:copy>
</xsl:template>
<xsl:template match='u:unattend/u:settings/u:component[@name="Microsoft-Windows-Shell-Setup"]/u:UserAccounts[not(u:LocalAccounts)]'>
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
<xsl:if test="$installationType = 'Client'">
<xsl:element name="LocalAccounts" namespace="{namespace-uri()}">
<xsl:element name="LocalAccount" namespace="{namespace-uri()}">
<xsl:attribute name="wcm:action">add</xsl:attribute>
<xsl:element name="Description" namespace="{namespace-uri()}">Admin user</xsl:element>
<xsl:element name="DisplayName" namespace="{namespace-uri()}">Admin</xsl:element>
<xsl:element name="Group" namespace="{namespace-uri()}">Administrators</xsl:element>
<xsl:element name="Name" namespace="{namespace-uri()}">Admin</xsl:element>
</xsl:element>
</xsl:element>
</xsl:if>
</xsl:copy>
</xsl:template>
<xsl:template match='u:unattend/u:settings/u:component[@name="Microsoft-Windows-Setup"]/u:UserData'>
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:if test="$productKey">
<xsl:element name="ProductKey" namespace="{namespace-uri()}">
<xsl:element name="Key" namespace="{namespace-uri()}">
<xsl:value-of select="$productKey"/>
</xsl:element>
<xsl:element name="WillShowUI" namespace="{namespace-uri()}">OnError</xsl:element>
</xsl:element>
</xsl:if>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match='u:unattend/u:settings/u:component'>
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:attribute name="processorArchitecture">
<xsl:value-of select="$processorArchitecture"/>
</xsl:attribute>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match='u:unattend/u:settings[@pass="specialize"]/u:component[@name="Microsoft-Windows-Shell-Setup"]'>
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:attribute name="processorArchitecture">
<xsl:value-of select="$processorArchitecture"/>
</xsl:attribute>
<xsl:if test="$productKey">
<xsl:element name="ProductKey" namespace="{namespace-uri()}">
<xsl:value-of select="$productKey"/>
</xsl:element>
</xsl:if>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="comment()"/>
</xsl:stylesheet>