This commit is contained in:
rbalsleyMSFT
2024-04-18 16:11:58 -07:00
3 changed files with 221 additions and 71 deletions
+30 -30
View File
@@ -130,26 +130,26 @@ $DiskID = $PhysicalDeviceID.substring($PhysicalDeviceID.length - 1,1)
WriteLog "DiskID is $DiskID"
#COMMENT THIS WHOLE BLOCK OUT ONCE FFUPROVIDER FIX IS IN
#Modify diskpart answer files if DiskID not 0
# $UEFIFFUPartitions = 'x:\CreateUEFI-FFU-Partitions.txt'
$ExtendPartition = 'x:\ExtendPartition-UEFI.txt'
# #Modify diskpart answer files if DiskID not 0
# # $UEFIFFUPartitions = 'x:\CreateUEFI-FFU-Partitions.txt'
# $ExtendPartition = 'x:\ExtendPartition-UEFI.txt'
If ($DiskID -ne '0'){
WriteLog 'DiskID is not 0. Need to modify diskpart answer files'
# try {
# Set-DiskpartAnswerFiles $UEFIFFUPartitions $DiskID
# }
# catch {
# WriteLog "Modifying $UEFIFFUPartitions failed with error: $_"
# }
# If ($DiskID -ne '0'){
# WriteLog 'DiskID is not 0. Need to modify diskpart answer files'
# # try {
# # Set-DiskpartAnswerFiles $UEFIFFUPartitions $DiskID
# # }
# # catch {
# # WriteLog "Modifying $UEFIFFUPartitions failed with error: $_"
# # }
try {
Set-DiskpartAnswerFiles $ExtendPartition $DiskID
}
catch {
WriteLog "Modifying $ExtendPartition failed with error: $_"
}
}
# try {
# Set-DiskpartAnswerFiles $ExtendPartition $DiskID
# }
# catch {
# WriteLog "Modifying $ExtendPartition failed with error: $_"
# }
# }
#Find FFU Files
[array]$FFUFiles = @(Get-ChildItem -Path $USBDrive*.ffu)
@@ -265,7 +265,7 @@ if ($Unattend -and $UnattendPrefix){
#Get serial number to append. This can make names longer than 15 characters. Trim any leading or trailing whitespace
$serial = (Get-CimInstance -ClassName win32_bios).SerialNumber.Trim()
#Combine prefix with serial
$computername = $PrefixToUse + $serial
$computername = ($PrefixToUse + $serial) -replace "\s","" # Remove spaces because windows does not support spaces in the computer names
#If computername is longer than 15 characters, reduce to 15. Sysprep/unattend doesn't like ComputerName being longer than 15 characters even though Windows accepts it
If ($computername.Length -gt 15){
$computername = $computername.substring(0,15)
@@ -476,19 +476,19 @@ else{
# }
#COMMENT THIS WHOLE BLOCK OUT AFTER FFUPROVIDER FIX IS IN
# Extend Windows partition and create recovery partition
Writelog 'Extending Windows partition'
Invoke-Process diskpart.exe "/S $ExtendPartition"
if($LASTEXITCODE -eq 0){
WriteLog 'Successfully extended Windows partition and created recovery partition'
}
else{
Writelog "Failed to extend Windows partition and/or create recovery partition - LastExitCode = $LASTEXITCODE"
}
# # Extend Windows partition and create recovery partition
# Writelog 'Extending Windows partition'
# Invoke-Process diskpart.exe "/S $ExtendPartition"
# if($LASTEXITCODE -eq 0){
# WriteLog 'Successfully extended Windows partition and created recovery partition'
# }
# else{
# Writelog "Failed to extend Windows partition and/or create recovery partition - LastExitCode = $LASTEXITCODE"
# }
#UNCOMMENT THIS AFTER FFUPROVIDER FIX IS IN
#Set W: drive letter to Windows partition
#Get-Disk | Where-Object Number -eq $DiskID | Get-Partition | Where-Object PartitionNumber -eq 3 | Set-Partition -NewDriveLetter W
# Set W: drive letter to Windows partition
Get-Disk | Where-Object Number -eq $DiskID | Get-Partition | Where-Object PartitionNumber -eq 3 | Set-Partition -NewDriveLetter W
#Copy modified WinRE if folder exists, else copy inbox WinRE
$WinRE = $USBDrive + "WinRE\winre.wim"