mirror of
https://github.com/rbalsleyMSFT/FFU.git
synced 2026-06-14 02:09:35 -06:00
Correct Logic for Dirve letters and add Dirve Info
to the write-host selection for Disks.
This commit is contained in:
@@ -2927,19 +2927,41 @@ Function Get-USBDrive {
|
|||||||
WriteLog 'Found external hard disk media drives'
|
WriteLog 'Found external hard disk media drives'
|
||||||
WriteLog 'Will prompt for user input to select the drive to use to prevent accidental data loss'
|
WriteLog 'Will prompt for user input to select the drive to use to prevent accidental data loss'
|
||||||
WriteLog 'If you do not want to be prompted for this in the future, set -PromptExternalHardDiskMedia to $false'
|
WriteLog 'If you do not want to be prompted for this in the future, set -PromptExternalHardDiskMedia to $false'
|
||||||
|
|
||||||
for ($i = 0; $i -lt $ExternalHardDiskDrives.Count; $i++) {
|
for ($i = 0; $i -lt $ExternalHardDiskDrives.Count; $i++) {
|
||||||
|
$ExternalDiskNumber = $ExternalHardDiskDrives[$i].DeviceID.Replace("\\.\PHYSICALDRIVE", "")
|
||||||
|
$ExternalDisk = Get-Disk -Number $ExternalDiskNumber
|
||||||
if ($VerbosePreference -ne 'Continue'){
|
if ($VerbosePreference -ne 'Continue'){
|
||||||
Write-Host ("{0}: {1}" -f ($i + 1), $ExternalHardDiskDrives[$i].Model)
|
# Write-Host ("{0}: {1}" -f ($i + 1), $ExternalHardDiskDrives[$i].Model)
|
||||||
|
Write-Host ("Drive {0}: {1} SN/{2} PartitionStyle={3} Status={4}" -f ($i + 1), $ExternalDisk.FriendlyName , $ExternalHardDiskDrives[$i].serialnumber, $ExternalDisk.PartitionStyle,$ExternalDisk.OperationalStatus ) -ForegroundColor Green
|
||||||
}
|
}
|
||||||
WriteLog ("{0}: {1}" -f ($i + 1), $ExternalHardDiskDrives[$i].Model)
|
WriteLog ("Drive {0}: {1} SN/{2} PartitionStyle={3} Status={4}" -f ($i + 1), $ExternalDisk.FriendlyName , $ExternalHardDiskDrives[$i].serialnumber, $ExternalDisk.PartitionStyle,$ExternalDisk.OperationalStatus )
|
||||||
}
|
}
|
||||||
$inputChoice = Read-Host "Enter the number corresponding to the external hard disk media drive you want to use"
|
while ($true) {
|
||||||
|
try {
|
||||||
|
# Ask the user for input
|
||||||
|
#$userInput = Read-Host "Please enter a number"
|
||||||
|
$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
|
||||||
|
Write-Host "You selected Disk: $ISnumber"
|
||||||
$selectedIndex = $inputChoice - 1
|
$selectedIndex = $inputChoice - 1
|
||||||
|
break
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
# If the input is not a valid number, display an error message
|
||||||
|
Write-Host "Invalid input. Please try again."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($selectedIndex -ge 0 -and $selectedIndex -lt $ExternalHardDiskDrives.Count) {
|
if ($selectedIndex -ge 0 -and $selectedIndex -lt $ExternalHardDiskDrives.Count) {
|
||||||
$USBDrives = $ExternalHardDiskDrives[$selectedIndex]
|
$USBDrives = $ExternalHardDiskDrives[$selectedIndex]
|
||||||
} else {
|
} else {
|
||||||
Write-Error "Invalid selection. Exiting."
|
Write-Warning "Invalid selection. Exiting." | Out-Null
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user