/
MDT-GenerateTSini.ps1
244 lines (228 loc) · 15.9 KB
/
MDT-GenerateTSini.ps1
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
<#
.Synopsis
MDT Custom CustomSettings.ini Generator
.DESCRIPTION
Creates a task sequence specific CustomSettings.ini
.EXAMPLE
MDT-GenerateTSini.ps1
.NOTES
Created: 2017-08-28
Version: 1.0
Author - Anton Romanyuk
Twitter: @admiraltolwyn
Blog : http://www.vacuumbreather.com
Disclaimer:
This script is provided 'AS IS' with no warranties, confers no rights and
is not supported by the author.
.LINK
http://www.vacuumbreather.com
.NOTES
1. Modify parameters to match your deployment share
2. Run the script
3. Verify content of the resulting INI file and copy it into the Control folder
#>
cls
#---------------------------------------------------------------------------
# Adjust these variables if necessary
$con_lis = @("AT","BE","CH","DE","ES","GR","HU","LU","NL","PL","PT","RU","SE","TR")
$src_xml = "\\MDT01\W10$\Control\Packages.xml" #package list
$w10_ver = "10.0.14393.0" # W10 build number, has to match target OS build
$w10_dir = "Windows 10 1607 Enterprise x64" #OS folder, required for .NET 3.5 sources
$w10_ts = "10_1607" #Task Sequence ID
#---------------------------------------------------------------------------
$cur_date = Get-Date
$cab_array = @()
$lan_xml = [xml](Get-Content $src_xml)
#create custom package array
ForEach ($cab in $lan_xml.packages.package)
{
$cab_array += @{
name=$cab.Name.ToString()
guid=$cab.guid.ToString()
version=$cab.version.ToString()
}
}
#This function generates LanguagePacks00x={guid} line
Function Gen-Content
{
$tmp = 'LanguagePacks00' + $counter + '=' + $tmp_filter.guid + "`r`n"
$global:cs_file += $tmp
}
#This function generates country specific list of language packs
Function Gen-LanList
{
$counter = 1
ForEach ($lan in $tmp_lis)
{
$global:cs_file += "`r`n;Language Pack `r`n"
$tmp_filter = $cab_array | Where-Object {$_.name -like '*LanguagePack-Package ' + $lan + '*' -and $_.version -eq $w10_ver}
If ($tmp_filter.guid)
{
Gen-Content
$counter++
}
$global:cs_file += ";Basic `r`n"
$tmp_filter = $cab_array | Where-Object {$_.name -like '*Basic-' + $lan + '*' -and $_.version -eq $w10_ver}
If ($tmp_filter.guid)
{
Gen-Content
$counter++
}
$global:cs_file += ";Text-to-speech `r`n"
$tmp_filter = $cab_array | Where-Object {$_.name -like '*TextToSpeech-' + $lan + '*' -and $_.version -eq $w10_ver}
If ($tmp_filter.guid)
{
Gen-Content
$counter++
}
$global:cs_file += ";Speech recognition `r`n"
$tmp_filter = $cab_array | Where-Object {$_.name -like '*-Speech-' + $lan + '*' -and $_.version -eq $w10_ver}
If ($tmp_filter.guid)
{
Gen-Content
$counter++
}
$global:cs_file += ";Optical character recognition `r`n"
$tmp_filter = $cab_array | Where-Object {$_.name -like '*OCR-' + $lan + '*' -and $_.version -eq $w10_ver}
If ($tmp_filter.guid)
{
Gen-Content
$counter++
}
$global:cs_file += ";handwriting recognition `r`n"
$tmp_filter = $cab_array | Where-Object {$_.name -like '*Handwriting-' + $lan + '*' -and $_.version -eq $w10_ver}
If ($tmp_filter.guid)
{
Gen-Content
$counter++
}
$global:cs_file += "`r`n"
}
}
$global:cs_file = ';Last updated: ' + $cur_date + "`r`n`r`n"
$global:cs_file += '[Settings]
Priority=ComputerNameAlias, SetLocale, Default
Properties=OSDCountry
[ComputerNameAlias]
OSDCountry=#Left("%OSDComputerName%",2)#
; This section acts as a switch for language packs
[SetLocale]
Subsection=%OSDCountry%'
$global:cs_file += "`r`n`r`n"
ForEach ($country in $con_lis)
{
If ($country -eq "AT")
{
$tmp_lis = @("de-de")
$switch = '[' + $country + ']'
#$switch = '[' + $lan.substring(3,2).toupper() + ']'
$global:cs_file += $switch
Gen-LanList
}
If ($country -eq "BE")
{
$tmp_lis = @("de-de","fr-fr","nl-nl")
$switch = '[' + $country + ']'
$global:cs_file += $switch
Gen-LanList
}
If ($country -eq "CH")
{
$tmp_lis = @("de-de","fr-fr","it-it")
$switch = '[' + $country + ']'
$global:cs_file += $switch
Gen-LanList
}
If ($country -eq "DE")
{
$tmp_lis = @("de-de")
$switch = '[' + $country + ']'
$global:cs_file += $switch
Gen-LanList
}
If ($country -eq "ES")
{
$tmp_lis = @("es-es")
$switch = '[' + $country + ']'
$global:cs_file += $switch
Gen-LanList
}
If ($country -eq "GR")
{
$tmp_lis = @("el-gr")
$switch = '[' + $country + ']'
$global:cs_file += $switch
Gen-LanList
}
If ($country -eq "HU")
{
$tmp_lis = @("hu-hu")
$switch = '[' + $country + ']'
$global:cs_file += $switch
Gen-LanList
}
If ($country -eq "LU")
{
$tmp_lis = @("de-de","fr-fr")
$switch = '[' + $country + ']'
$global:cs_file += $switch
Gen-LanList
}
If ($country -eq "BE")
{
$tmp_lis = @("de-de","fr-fr","nl-nl")
$switch = '[' + $country + ']'
$global:cs_file += $switch
Gen-LanList
}
If ($country -eq "NL")
{
$tmp_lis = @("nl-nl")
$switch = '[' + $country + ']'
$global:cs_file += $switch
Gen-LanList
}
If ($country -eq "PL")
{
$tmp_lis = @("pl-pl")
$switch = '[' + $country + ']'
$global:cs_file += $switch
Gen-LanList
}
If ($country -eq "PT")
{
$tmp_lis = @("pt-pt")
$switch = '[' + $country + ']'
$global:cs_file += $switch
Gen-LanList
}
If ($country -eq "RU")
{
$tmp_lis = @("ru-ru")
$switch = '[' + $country + ']'
$global:cs_file += $switch
Gen-LanList
}
If ($country -eq "SE")
{
$tmp_lis = @("sv-se")
$switch = '[' + $country + ']'
$global:cs_file += $switch
Gen-LanList
}
If ($country -eq "TR")
{
$tmp_lis = @("tr-tr")
$switch = '[' + $country + ']'
$global:cs_file += $switch
Gen-LanList
}
}
$global:cs_file += "[Default]
SkipCapture=YES
; NetFX 3.5 source path `r`n"
$global:cs_file += "WindowsSource=%DeployRoot%\Operating Systems\" + $w10_dir + "\sources\sxs" + "`r`n"
$global:cs_file +='
PrepareWinRE=YES
DisableTaskMgr=YES'
$global:cs_file | Out-File -FilePath $PSScriptRoot\CustomSettings_$w10_ts.ini -Encoding ascii -Force