-
Notifications
You must be signed in to change notification settings - Fork 5
/
New-UnattendXml.ps1
96 lines (96 loc) · 4.28 KB
/
New-UnattendXml.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
function New-UnattendXml {
[CmdletBinding()]
Param
(
# The password to have unattnd.xml set the local Administrator to
[Parameter(Mandatory)]
[ValidateNotNull()]
[ValidateNotNullOrEmpty()]
[Alias('password')]
[string]
$admpwd,
[Parameter(Mandatory)]
[string]
$outfile,
[Parameter]
[switch]
$WKS,
[Parameter]
[string]
$domainFQDN,
[Parameter]
[string]
$Adminuname,
[Parameter]
[string]
$domainNetBios
)
if ($WKS.IsPresent) {
$unattendTemplate = [xml]@"
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="specialize">
<component name="Microsoft-Windows-UnattendedJoin" 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">
<Identification>
<Credentials>
<Domain><<DomNetBios>></Domain>
<Password><<ADM_PWD>></Password>
<Username><<AdminUname>></Username>
</Credentials>
<JoinDomain><<DomainFQDN>></JoinDomain>
</Identification>
</component>
</settings>
</unattend>
"@
$unattendTemplate -replace "<<ADM_PWD>>", $admpwd
$unattendTemplate -replace "<<DomNetBios>>", $domainNetBios
$unattendTemplate -replace "<<AdminUname>>", $Adminuname
$unattendTemplate -replace "<<DomainFQDN>>", $domainFQDN
$unattendTemplate | Out-File -FilePath $outfile -Encoding utf8
}
else {
$unattendTemplate = [xml]@"
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<servicing>
<package action="install" permanence="removable">
<assemblyIdentity name="Microsoft-Windows-NetFx3-OnDemand-Package" version="10.0.14393.0" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" />
<source location="c:\data\microsoft-windows-netfx3-ondemand-package.cab" />
</package>
</servicing>
<settings pass="oobeSystem">
<component name="Microsoft-Windows-Shell-Setup" 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">
<UserAccounts>
<AdministratorPassword>
<Value><<ADM_PWD>></Value>
<PlainText>True</PlainText>
</AdministratorPassword>
</UserAccounts>
<OOBE>
<VMModeOptimizations>
<SkipNotifyUILanguageChange>true</SkipNotifyUILanguageChange>
<SkipWinREInitialization>true</SkipWinREInitialization>
</VMModeOptimizations>
<SkipMachineOOBE>true</SkipMachineOOBE>
<HideEULAPage>true</HideEULAPage>
<HideLocalAccountScreen>true</HideLocalAccountScreen>
<ProtectYourPC>3</ProtectYourPC>
<HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
<NetworkLocation>Work</NetworkLocation>
<HideOnlineAccountScreens>true</HideOnlineAccountScreens>
</OOBE>
</component>
<component name="Microsoft-Windows-International-Core" 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">
<InputLocale>en-au</InputLocale>
<SystemLocale>en-us</SystemLocale>
<UILanguage>en-au</UILanguage>
<UILanguageFallback>en-us</UILanguageFallback>
<UserLocale>en-au</UserLocale>
</component>
</settings>
</unattend>
"@
$unattendTemplate -replace "<<ADM_PWD>>", $admpwd | Out-File -FilePath $outfile -Encoding utf8
}
}