Improve image index input validation in tiny11maker.ps1

- Added validation to ensure the entered index is valid by checking
against available indices in the Windows image file.
- Introduced a loop to repeatedly prompt the user until a valid index is provided.
This commit is contained in:
Miiraak 2025-02-19 01:35:15 +01:00
parent d37e3e1b01
commit 0241e51814

View File

@ -87,7 +87,13 @@ Start-Sleep -Seconds 2
Clear-Host
Write-Host "Getting image information:"
Get-WindowsImage -ImagePath $ScratchDisk\tiny11\sources\install.wim
$index = Read-Host "Please enter the image index"
$index = Read-Host "Please enter the image index : "
$ImagesIndex = (Get-WindowsImage -ImagePath $ScratchDisk\tiny11\sources\install.wim).ImageIndex
while ($ImagesIndex -notcontains $index) {
$index = Read-Host "Please enter a valide image index : "
}
Write-Host "Mounting Windows image. This may take a while."
$wimFilePath = "$ScratchDisk\tiny11\sources\install.wim"
& takeown "/F" $wimFilePath