Skip to content

Commit 4bdb7b1

Browse files
author
Jaromir Kaspar
authored
Merge pull request #390 from microsoft/dev
OEMInformation fix
2 parents 0b43feb + 91a980b commit 4bdb7b1

File tree

2 files changed

+36
-16
lines changed

2 files changed

+36
-16
lines changed

Scripts/2_CreateParentDisks.ps1

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ If (-not $isAdmin) {
3636
Remove-Item "$Path\Unattend.xml"
3737
}
3838
$unattendFile = New-Item "$Path\Unattend.xml" -type File
39+
3940
$fileContent = @"
4041
<?xml version='1.0' encoding='utf-8'?>
4142
<unattend xmlns="urn:schemas-microsoft-com:unattend" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
@@ -56,10 +57,7 @@ If (-not $isAdmin) {
5657
<settings pass="specialize">
5758
<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">
5859
<ComputerName>$Computername</ComputerName>
59-
<OEMInformation>
60-
<SupportProvider>WSLab</SupportProvider>
61-
<SupportURL>https://aka.ms/wslab</SupportURL>
62-
</OEMInformation>
60+
$oeminformation
6361
<RegisteredOwner>PFE</RegisteredOwner>
6462
<RegisteredOrganization>Contoso</RegisteredOrganization>
6563
</component>
@@ -564,6 +562,10 @@ If (-not $isAdmin) {
564562
}
565563
}
566564

565+
#Get VM Version
566+
[System.Version]$VMVersion=(Get-WindowsImage -ImagePath $VHDPath -Index 1).Version
567+
WriteInfo "`t VM Version is $($VMVersion.Build).$($VMVersion.Revision)"
568+
567569
#If the switch does not already exist, then create a switch with the name $SwitchName
568570
if (-not [bool](Get-VMSwitch -Name $Switchname -ErrorAction SilentlyContinue)) {
569571
WriteInfoHighlighted "`t Creating temp hydration switch $Switchname"
@@ -585,6 +587,17 @@ If (-not $isAdmin) {
585587
}
586588

587589
#Apply Unattend to VM
590+
if ($VMVersion.Build -ge 17763){
591+
$oeminformation=@"
592+
<OEMInformation>
593+
<SupportProvider>WSLab</SupportProvider>
594+
<SupportURL>https://aka.ms/wslab</SupportURL>
595+
</OEMInformation>
596+
"@
597+
}else{
598+
$oeminformation=$null
599+
}
600+
588601
WriteInfoHighlighted "`t Applying Unattend and copying Powershell DSC Modules"
589602
if (Test-Path $mountdir){
590603
Remove-Item -Path $mountdir -Recurse -Force
@@ -594,6 +607,7 @@ If (-not $isAdmin) {
594607
}
595608
$unattendfile=CreateUnattendFileVHD -Computername $DCName -AdminPassword $AdminPassword -path "$PSScriptRoot\temp\" -TimeZone $TimeZone
596609
New-item -type directory -Path $mountdir -force
610+
[System.Version]$VMVersion=(Get-WindowsImage -ImagePath $VHDPath -Index 1).Version
597611
Mount-WindowsImage -Path $mountdir -ImagePath $VHDPath -Index 1
598612
Use-WindowsUnattend -Path $mountdir -UnattendPath $unattendFile
599613
#&"$PSScriptRoot\Temp\dism\dism" /mount-image /imagefile:$vhdpath /index:1 /MountDir:$mountdir

Scripts/3_Deploy.ps1

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,7 @@ If (-not $isAdmin) {
6666
</settings>
6767
<settings pass="specialize">
6868
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
69-
<OEMInformation>
70-
<SupportProvider>WSLab</SupportProvider>
71-
<SupportURL>https://aka.ms/wslab</SupportURL>
72-
</OEMInformation>
69+
$oeminformation
7370
<RegisteredOwner>PFE</RegisteredOwner>
7471
<RegisteredOrganization>PFE Inc.</RegisteredOrganization>
7572
</component>
@@ -118,10 +115,7 @@ If (-not $isAdmin) {
118115
<settings pass="specialize">
119116
<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">
120117
<ComputerName>$Computername</ComputerName>
121-
<OEMInformation>
122-
<SupportProvider>WSLab</SupportProvider>
123-
<SupportURL>https://aka.ms/wslab</SupportURL>
124-
</OEMInformation>
118+
$oeminformation
125119
<RegisteredOwner>PFE</RegisteredOwner>
126120
<RegisteredOrganization>PFE Inc.</RegisteredOrganization>
127121
</component>
@@ -186,10 +180,7 @@ If (-not $isAdmin) {
186180
<settings pass="specialize">
187181
<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">
188182
<ComputerName>$Computername</ComputerName>
189-
<OEMInformation>
190-
<SupportProvider>WSLab</SupportProvider>
191-
<SupportURL>https://aka.ms/wslab</SupportURL>
192-
</OEMInformation>
183+
$oeminformation
193184
<RegisteredOwner>PFE</RegisteredOwner>
194185
<RegisteredOrganization>PFE Inc.</RegisteredOrganization>
195186
</component>
@@ -432,6 +423,11 @@ If (-not $isAdmin) {
432423
}
433424
WriteInfoHighlighted "`t Creating OS VHD"
434425
New-VHD -ParentPath $serverparent.fullname -Path $vhdpath
426+
427+
#Get VM Version
428+
[System.Version]$VMVersion=(Get-WindowsImage -ImagePath $VHDPath -Index 1).Version
429+
WriteInfo "`t VM Version is $($VMVersion.Build).$($VMVersion.Revision)"
430+
435431
WriteInfo "`t Creating VM"
436432
if ($VMConfig.Generation -eq 1){
437433
$VMTemp=New-VM -Name $VMname -VHDPath $vhdpath -MemoryStartupBytes $VMConfig.MemoryStartupBytes -path "$LabFolder\VMs" -SwitchName $SwitchName -Generation 1
@@ -582,6 +578,16 @@ If (-not $isAdmin) {
582578
WriteInfo "`t`t No sync commands requested"
583579
}
584580

581+
if ($VMVersion.Build -ge 17763){
582+
$oeminformation=@"
583+
<OEMInformation>
584+
<SupportProvider>WSLab</SupportProvider>
585+
<SupportURL>https://aka.ms/wslab</SupportURL>
586+
</OEMInformation>
587+
"@
588+
}else{
589+
$oeminformation=$null
590+
}
585591
#configure native VLAN and AllowedVLANs
586592
WriteInfo "`t Configuring NativeVLAN and AllowedVLANs"
587593
if ($VMConfig.ManagementSubnetID -gt 0){

0 commit comments

Comments
 (0)