mirror of
https://github.com/rbalsleyMSFT/FFU.git
synced 2026-06-14 02:09:35 -06:00
Added Logic for FFU Selection to Check for Integer
or 'A' Fix Write Message to Display all FFUs found if not using -Verbose, currently displays nothing so numbering of FFUs is unkown for selection prompt Added Simple total Runtime and Start and Finish Time
This commit is contained in:
@@ -2616,7 +2616,7 @@ function New-PEMedia {
|
|||||||
#Remove-Item -Path "$WinPEFFUPath\media\boot\bootfix.bin" -Force | Out-null
|
#Remove-Item -Path "$WinPEFFUPath\media\boot\bootfix.bin" -Force | Out-null
|
||||||
# $WinPEISOName = 'WinPE_FFU_Capture.iso'
|
# $WinPEISOName = 'WinPE_FFU_Capture.iso'
|
||||||
$WinPEISOFile = $CaptureISO
|
$WinPEISOFile = $CaptureISO
|
||||||
# $Capture = $false
|
$Capture = $false
|
||||||
}
|
}
|
||||||
If ($Deploy) {
|
If ($Deploy) {
|
||||||
WriteLog "Copying $FFUDevelopmentPath\WinPEDeployFFUFiles\* to WinPE deploy media"
|
WriteLog "Copying $FFUDevelopmentPath\WinPEDeployFFUFiles\* to WinPE deploy media"
|
||||||
@@ -2636,7 +2636,7 @@ function New-PEMedia {
|
|||||||
# $WinPEISOName = 'WinPE_FFU_Deploy.iso'
|
# $WinPEISOName = 'WinPE_FFU_Deploy.iso'
|
||||||
$WinPEISOFile = $DeployISO
|
$WinPEISOFile = $DeployISO
|
||||||
|
|
||||||
# $Deploy = $false
|
$Deploy = $false
|
||||||
}
|
}
|
||||||
WriteLog 'Dismounting WinPE media'
|
WriteLog 'Dismounting WinPE media'
|
||||||
Dismount-WindowsImage -Path "$WinPEFFUPath\mount" -Save | Out-Null
|
Dismount-WindowsImage -Path "$WinPEFFUPath\mount" -Save | Out-Null
|
||||||
@@ -2652,22 +2652,12 @@ function New-PEMedia {
|
|||||||
WriteLog "Creating WinPE ISO at $WinPEISOFile"
|
WriteLog "Creating WinPE ISO at $WinPEISOFile"
|
||||||
# & "$OSCDIMG" -m -o -u2 -udfver102 -bootdata:2`#p0,e,b$OSCDIMGPath\etfsboot.com`#pEF,e,b$OSCDIMGPath\Efisys_noprompt.bin $WinPEFFUPath\media $FFUDevelopmentPath\$WinPEISOName | Out-null
|
# & "$OSCDIMG" -m -o -u2 -udfver102 -bootdata:2`#p0,e,b$OSCDIMGPath\etfsboot.com`#pEF,e,b$OSCDIMGPath\Efisys_noprompt.bin $WinPEFFUPath\media $FFUDevelopmentPath\$WinPEISOName | Out-null
|
||||||
if($WindowsArch -eq 'x64'){
|
if($WindowsArch -eq 'x64'){
|
||||||
if($Capture){
|
|
||||||
$OSCDIMGArgs = "-m -o -u2 -udfver102 -bootdata:2`#p0,e,b`"$OSCDIMGPath\etfsboot.com`"`#pEF,e,b`"$OSCDIMGPath\Efisys_noprompt.bin`" `"$WinPEFFUPath\media`" `"$WinPEISOFile`""
|
$OSCDIMGArgs = "-m -o -u2 -udfver102 -bootdata:2`#p0,e,b`"$OSCDIMGPath\etfsboot.com`"`#pEF,e,b`"$OSCDIMGPath\Efisys_noprompt.bin`" `"$WinPEFFUPath\media`" `"$WinPEISOFile`""
|
||||||
}
|
|
||||||
if($Deploy){
|
|
||||||
$OSCDIMGArgs = "-m -o -u2 -udfver102 -bootdata:2`#p0,e,b`"$OSCDIMGPath\etfsboot.com`"`#pEF,e,b`"$OSCDIMGPath\Efisys.bin`" `"$WinPEFFUPath\media`" `"$WinPEISOFile`""
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
elseif($WindowsArch -eq 'arm64'){
|
elseif($WindowsArch -eq 'arm64'){
|
||||||
if($Capture){
|
|
||||||
$OSCDIMGArgs = "-m -o -u2 -udfver102 -bootdata:1`#pEF,e,b`"$OSCDIMGPath\Efisys_noprompt.bin`" `"$WinPEFFUPath\media`" `"$WinPEISOFile`""
|
$OSCDIMGArgs = "-m -o -u2 -udfver102 -bootdata:1`#pEF,e,b`"$OSCDIMGPath\Efisys_noprompt.bin`" `"$WinPEFFUPath\media`" `"$WinPEISOFile`""
|
||||||
}
|
}
|
||||||
if($Deploy){
|
|
||||||
$OSCDIMGArgs = "-m -o -u2 -udfver102 -bootdata:1`#pEF,e,b`"$OSCDIMGPath\Efisys.bin`" `"$WinPEFFUPath\media`" `"$WinPEISOFile`""
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Invoke-Process $OSCDIMG $OSCDIMGArgs
|
Invoke-Process $OSCDIMG $OSCDIMGArgs
|
||||||
WriteLog "ISO created successfully"
|
WriteLog "ISO created successfully"
|
||||||
WriteLog "Cleaning up $WinPEFFUPath"
|
WriteLog "Cleaning up $WinPEFFUPath"
|
||||||
@@ -2959,7 +2949,14 @@ Function Get-USBDrive {
|
|||||||
|
|
||||||
|
|
||||||
if ($selectedIndex -ge 0 -and $selectedIndex -lt $ExternalHardDiskDrives.Count) {
|
if ($selectedIndex -ge 0 -and $selectedIndex -lt $ExternalHardDiskDrives.Count) {
|
||||||
|
if ($ExternalDisk.OperationalStatus -eq 'Offline') {
|
||||||
|
Write-Warning "Selected Drive is in an Offline State. Please check the drive status in Disk Manager and try again."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
else {
|
||||||
$USBDrives = $ExternalHardDiskDrives[$selectedIndex]
|
$USBDrives = $ExternalHardDiskDrives[$selectedIndex]
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Write-Warning "Invalid selection. Exiting." | Out-Null
|
Write-Warning "Invalid selection. Exiting." | Out-Null
|
||||||
exit 1
|
exit 1
|
||||||
@@ -3000,29 +2997,68 @@ Function New-DeploymentUSB {
|
|||||||
if ($CopyFFU.IsPresent) {
|
if ($CopyFFU.IsPresent) {
|
||||||
$FFUFiles = Get-ChildItem -Path "$BuildUSBPath\FFU" -Filter "*.ffu"
|
$FFUFiles = Get-ChildItem -Path "$BuildUSBPath\FFU" -Filter "*.ffu"
|
||||||
|
|
||||||
if ($FFUFiles.Count -eq 1) {
|
|
||||||
|
if (-not $FFUFiles) {
|
||||||
|
# WriteLog "No FFU files found in the current directory."
|
||||||
|
Write-Error "No FFU files found in the current directory."
|
||||||
|
Return
|
||||||
|
}
|
||||||
|
|
||||||
|
elseif ($FFUFiles.Count -eq 1) {
|
||||||
$SelectedFFUFile = $FFUFiles.FullName
|
$SelectedFFUFile = $FFUFiles.FullName
|
||||||
}
|
}
|
||||||
elseif ($FFUFiles.Count -gt 1) {
|
elseif ($FFUFiles.Count -gt 1) {
|
||||||
WriteLog 'Found multiple FFU files'
|
WriteLog 'Found multiple FFU files'
|
||||||
|
Write-Warning 'Found multiple FFU files'
|
||||||
for ($i = 0; $i -lt $FFUFiles.Count; $i++) {
|
for ($i = 0; $i -lt $FFUFiles.Count; $i++) {
|
||||||
WriteLog ("{0}: {1}" -f ($i + 1), $FFUFiles[$i].Name)
|
WriteLog ("FFU {0}: {1} Modified: {2}" -f ($i + 1), $FFUFiles[$i].Name, $FFUFiles[$i].LastWriteTime)
|
||||||
|
if ($VerbosePreference -ne 'Continue') {
|
||||||
|
Write-Host ("FFU {0}: {1} Modified: {2}" -f ($i + 1), $FFUFiles[$i].Name, $FFUFiles[$i].LastWriteTime) -ForegroundColor Green
|
||||||
}
|
}
|
||||||
$inputChoice = Read-Host "Enter the number corresponding to the FFU file you want to copy or 'A' to copy all FFU files"
|
|
||||||
|
|
||||||
|
}
|
||||||
|
#$inputChoice = Read-Host "Enter the number corresponding to the FFU file you want to copy or 'A' to copy all FFU files"
|
||||||
|
$inputChoice = $(Write-Host "Enter the number corresponding to the external hard disk media drive you want to use: " -ForegroundColor DarkYellow -NoNewline; Read-Host)
|
||||||
|
|
||||||
|
Write-Host "You selected FFU: $inputChoice"
|
||||||
|
WriteLog "You selected FFU: $inputChoice"
|
||||||
|
|
||||||
|
while ($true) {
|
||||||
if ($inputChoice -eq 'A') {
|
if ($inputChoice -eq 'A') {
|
||||||
$SelectedFFUFile = $FFUFiles.FullName
|
$SelectedFFUFile = $FFUFiles.FullName
|
||||||
|
Write-Host "You selected $inputChoice"
|
||||||
|
break
|
||||||
}
|
}
|
||||||
elseif ($inputChoice -ge 1 -and $inputChoice -le $FFUFiles.Count) {
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
# $inputChoice = $(Write-Host "Enter the number corresponding to the external hard disk media drive you want to use: " -ForegroundColor DarkYellow -NoNewline; Read-Host)
|
||||||
|
|
||||||
|
# Convert the input to a float
|
||||||
|
$ISnumber = [float]$inputChoice
|
||||||
|
|
||||||
|
# Display the entered number for debuggin
|
||||||
|
#Write-Host "You selected Disk: $ISnumber"
|
||||||
|
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
# If the input is not a valid number, display an error message
|
||||||
|
Write-Host "Invalid input. Please try again."
|
||||||
|
|
||||||
|
}
|
||||||
|
if ($inputChoice -ge 1 -and $inputChoice -le $FFUFiles.Count) {
|
||||||
$selectedIndex = $inputChoice - 1
|
$selectedIndex = $inputChoice - 1
|
||||||
|
Write-Host "You Selected FFU $selectedIndex"
|
||||||
$SelectedFFUFile = $FFUFiles[$selectedIndex].FullName
|
$SelectedFFUFile = $FFUFiles[$selectedIndex].FullName
|
||||||
|
break
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Write-Host "Invalid FFU Number. Please try again."
|
||||||
|
$inputChoice = $(Write-Host "Enter the number corresponding to the external hard disk media drive you want to use: " -ForegroundColor DarkYellow -NoNewline; Read-Host)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
WriteLog "$SelectedFFUFile was selected"
|
WriteLog "$SelectedFFUFile was selected"
|
||||||
}
|
Write-Host "$SelectedFFUFile was selected"
|
||||||
else {
|
|
||||||
WriteLog "No FFU files found in the current directory."
|
|
||||||
Write-Error "No FFU files found in the current directory."
|
|
||||||
Return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$counter = 0
|
$counter = 0
|
||||||
@@ -3314,7 +3350,9 @@ function Clear-InstallAppsandSysprep {
|
|||||||
if (Test-Path -Path $Logfile) {
|
if (Test-Path -Path $Logfile) {
|
||||||
Remove-item -Path $LogFile -Force
|
Remove-item -Path $LogFile -Force
|
||||||
}
|
}
|
||||||
Write-Host "FFU build process has begun. This process can take 20 minutes or more. Please do not close this window or any additional windows that pop up"
|
$startTime = Get-Date
|
||||||
|
Write-Host "FFU build process has begun at" $startTime -ForegroundColor DarkYellow
|
||||||
|
Write-Host "This process can take 20 minutes or more. Please do not close this window or any additional windows that pop up"
|
||||||
Write-Host "To track progress, please open the log file $Logfile or use the -Verbose parameter next time"
|
Write-Host "To track progress, please open the log file $Logfile or use the -Verbose parameter next time"
|
||||||
|
|
||||||
WriteLog 'Begin Logging'
|
WriteLog 'Begin Logging'
|
||||||
@@ -3968,4 +4006,19 @@ Remove-Item -Path .\dirty.txt -Force | out-null
|
|||||||
if ($VerbosePreference -ne 'Continue'){
|
if ($VerbosePreference -ne 'Continue'){
|
||||||
Write-Host 'Script complete'
|
Write-Host 'Script complete'
|
||||||
}
|
}
|
||||||
|
# Record the end time
|
||||||
|
$endTime = Get-Date
|
||||||
|
Write-Host "FFU build process has completed at" $endTime -ForegroundColor DarkYellow
|
||||||
|
|
||||||
|
# Calculate the total run time
|
||||||
|
$runTime = $endTime - $startTime
|
||||||
|
$runTimeInMinutes = [math]::Round($runTime.TotalMinutes, 2)
|
||||||
|
|
||||||
|
# Format the runtime as minutes and seconds
|
||||||
|
$runTimeFormatted = 'Duration: {0:mm} min {0:ss} sec' -f $runTime
|
||||||
|
|
||||||
|
Write-Host $runTimeFormatted -ForegroundColor DarkGreen
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
WriteLog 'Script complete'
|
WriteLog 'Script complete'
|
||||||
|
|||||||
Reference in New Issue
Block a user